/*! * jQuery Cookie Plugin v1.4.1 * https://github.com/carhartl/jquery-cookie * * Copyright 2013 Klaus Hartl * Released under the MIT license */ (function (factory) { if (typeof define === 'function' && define.amd) { // AMD define(['jquery'], factory); } else if (typeof exports === 'object') { // CommonJS factory(require('jquery')); } else { // Browser globals factory(jQuery); } }(function ($) { var pluses = /\+/g; function encode(s) { return config.raw ? s : encodeURIComponent(s); } function decode(s) { return config.raw ? s : decodeURIComponent(s); } function stringifyCookieValue(value) { return encode(config.json ? JSON.stringify(value) : String(value)); } function parseCookieValue(s) { if (s.indexOf('"') === 0) { // This is a quoted cookie as according to RFC2068, unescape... s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\'); } try { // Replace server-side written pluses with spaces. // If we can't decode the cookie, ignore it, it's unusable. // If we can't parse the cookie, ignore it, it's unusable. s = decodeURIComponent(s.replace(pluses, ' ')); return config.json ? JSON.parse(s) : s; } catch(e) {} } function read(s, converter) { var value = config.raw ? s : parseCookieValue(s); return $.isFunction(converter) ? converter(value) : value; } var config = $.cookie = function (key, value, options) { // Write if (value !== undefined && !$.isFunction(value)) { options = $.extend({}, config.defaults, options); if (typeof options.expires === 'number') { var days = options.expires, t = options.expires = new Date(); t.setTime(+t + days * 864e+5); } return (document.cookie = [ encode(key), '=', stringifyCookieValue(value), options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE options.path ? '; path=' + options.path : '', options.domain ? '; domain=' + options.domain : '', options.secure ? '; secure' : '' ].join('')); } // Read var result = key ? undefined : {}; // To prevent the for loop in the first place assign an empty array // in case there are no cookies at all. Also prevents odd result when // calling $.cookie(). var cookies = document.cookie ? document.cookie.split('; ') : []; for (var i = 0, l = cookies.length; i < l; i++) { var parts = cookies[i].split('='); var name = decode(parts.shift()); var cookie = parts.join('='); if (key && key === name) { // If second argument (value) is a function it's a converter... result = read(cookie, value); break; } // Prevent storing a cookie that we couldn't decode. if (!key && (cookie = read(cookie)) !== undefined) { result[name] = cookie; } } return result; }; config.defaults = {}; $.removeCookie = function (key, options) { if ($.cookie(key) === undefined) { return false; } // Must not alter options, thus extending a fresh object... $.cookie(key, '', $.extend({}, options, { expires: -1 })); return !$.cookie(key); }; })); ; /** * @file * Drupal Bootstrap object. */ /** * All Drupal Bootstrap JavaScript APIs are contained in this namespace. * * @namespace */ (function (_, $, Drupal, drupalSettings) { 'use strict'; var Bootstrap = { processedOnce: {}, settings: drupalSettings.bootstrap || {} }; /** * Wraps Drupal.checkPlain() to ensure value passed isn't empty. * * Encodes special characters in a plain-text string for display as HTML. * * @param {string} str * The string to be encoded. * * @return {string} * The encoded string. * * @ingroup sanitization */ Bootstrap.checkPlain = function (str) { return str && Drupal.checkPlain(str) || ''; }; /** * Creates a jQuery plugin. * * @param {String} id * A jQuery plugin identifier located in $.fn. * @param {Function} plugin * A constructor function used to initialize the for the jQuery plugin. * @param {Boolean} [noConflict] * Flag indicating whether or not to create a ".noConflict()" helper method * for the plugin. */ Bootstrap.createPlugin = function (id, plugin, noConflict) { // Immediately return if plugin doesn't exist. if ($.fn[id] !== void 0) { return this.fatal('Specified jQuery plugin identifier already exists: @id. Use Drupal.bootstrap.replacePlugin() instead.', {'@id': id}); } // Immediately return if plugin isn't a function. if (typeof plugin !== 'function') { return this.fatal('You must provide a constructor function to create a jQuery plugin "@id": @plugin', {'@id': id, '@plugin': plugin}); } // Add a ".noConflict()" helper method. this.pluginNoConflict(id, plugin, noConflict); $.fn[id] = plugin; }; /** * Diff object properties. * * @param {...Object} objects * Two or more objects. The first object will be used to return properties * values. * * @return {Object} * Returns the properties of the first passed object that are not present * in all other passed objects. */ Bootstrap.diffObjects = function (objects) { var args = Array.prototype.slice.call(arguments); return _.pick(args[0], _.difference.apply(_, _.map(args, function (obj) { return Object.keys(obj); }))); }; /** * Map of supported events by regular expression. * * @type {Object} */ Bootstrap.eventMap = { Event: /^(?:load|unload|abort|error|select|change|submit|reset|focus|blur|resize|scroll)$/, MouseEvent: /^(?:click|dblclick|mouse(?:down|enter|leave|up|over|move|out))$/, KeyboardEvent: /^(?:key(?:down|press|up))$/, TouchEvent: /^(?:touch(?:start|end|move|cancel))$/ }; /** * Extends a jQuery Plugin. * * @param {String} id * A jQuery plugin identifier located in $.fn. * @param {Function} callback * A constructor function used to initialize the for the jQuery plugin. * * @return {Function|Boolean} * The jQuery plugin constructor or FALSE if the plugin does not exist. */ Bootstrap.extendPlugin = function (id, callback) { // Immediately return if plugin doesn't exist. if (typeof $.fn[id] !== 'function') { return this.fatal('Specified jQuery plugin identifier does not exist: @id', {'@id': id}); } // Immediately return if callback isn't a function. if (typeof callback !== 'function') { return this.fatal('You must provide a callback function to extend the jQuery plugin "@id": @callback', {'@id': id, '@callback': callback}); } // Determine existing plugin constructor. var constructor = $.fn[id] && $.fn[id].Constructor || $.fn[id]; var plugin = callback.apply(constructor, [this.settings]); if (!$.isPlainObject(plugin)) { return this.fatal('Returned value from callback is not a plain object that can be used to extend the jQuery plugin "@id": @obj', {'@obj': plugin}); } this.wrapPluginConstructor(constructor, plugin, true); return $.fn[id]; }; Bootstrap.superWrapper = function (parent, fn) { return function () { var previousSuper = this.super; this.super = parent; var ret = fn.apply(this, arguments); if (previousSuper) { this.super = previousSuper; } else { delete this.super; } return ret; }; }; /** * Provide a helper method for displaying when something is went wrong. * * @param {String} message * The message to display. * @param {Object} [args] * An arguments to use in message. * * @return {Boolean} * Always returns FALSE. */ Bootstrap.fatal = function (message, args) { if (this.settings.dev && console.warn) { for (var name in args) { if (args.hasOwnProperty(name) && typeof args[name] === 'object') { args[name] = JSON.stringify(args[name]); } } Drupal.throwError(new Error(Drupal.formatString(message, args))); } return false; }; /** * Intersects object properties. * * @param {...Object} objects * Two or more objects. The first object will be used to return properties * values. * * @return {Object} * Returns the properties of first passed object that intersects with all * other passed objects. */ Bootstrap.intersectObjects = function (objects) { var args = Array.prototype.slice.call(arguments); return _.pick(args[0], _.intersection.apply(_, _.map(args, function (obj) { return Object.keys(obj); }))); }; /** * Normalizes an object's values. * * @param {Object} obj * The object to normalize. * * @return {Object} * The normalized object. */ Bootstrap.normalizeObject = function (obj) { if (!$.isPlainObject(obj)) { return obj; } for (var k in obj) { if (typeof obj[k] === 'string') { if (obj[k] === 'true') { obj[k] = true; } else if (obj[k] === 'false') { obj[k] = false; } else if (obj[k].match(/^[\d-.]$/)) { obj[k] = parseFloat(obj[k]); } } else if ($.isPlainObject(obj[k])) { obj[k] = Bootstrap.normalizeObject(obj[k]); } } return obj; }; /** * An object based once plugin (similar to jquery.once, but without the DOM). * * @param {String} id * A unique identifier. * @param {Function} callback * The callback to invoke if the identifier has not yet been seen. * * @return {Bootstrap} */ Bootstrap.once = function (id, callback) { // Immediately return if identifier has already been processed. if (this.processedOnce[id]) { return this; } callback.call(this, this.settings); this.processedOnce[id] = true; return this; }; /** * Provide jQuery UI like ability to get/set options for Bootstrap plugins. * * @param {string|object} key * A string value of the option to set, can be dot like to a nested key. * An object of key/value pairs. * @param {*} [value] * (optional) A value to set for key. * * @returns {*} * - Returns nothing if key is an object or both key and value parameters * were provided to set an option. * - Returns the a value for a specific setting if key was provided. * - Returns an object of key/value pairs of all the options if no key or * value parameter was provided. * * @see https://github.com/jquery/jquery-ui/blob/master/ui/widget.js */ Bootstrap.option = function (key, value) { var options = $.isPlainObject(key) ? $.extend({}, key) : {}; // Get all options (clone so it doesn't reference the internal object). if (arguments.length === 0) { return $.extend({}, this.options); } // Get/set single option. if (typeof key === "string") { // Handle nested keys in dot notation. // e.g., "foo.bar" => { foo: { bar: true } } var parts = key.split('.'); key = parts.shift(); var obj = options; if (parts.length) { for (var i = 0; i < parts.length - 1; i++) { obj[parts[i]] = obj[parts[i]] || {}; obj = obj[parts[i]]; } key = parts.pop(); } // Get. if (arguments.length === 1) { return obj[key] === void 0 ? null : obj[key]; } // Set. obj[key] = value; } // Set multiple options. $.extend(true, this.options, options); }; /** * Adds a ".noConflict()" helper method if needed. * * @param {String} id * A jQuery plugin identifier located in $.fn. * @param {Function} plugin * @param {Function} plugin * A constructor function used to initialize the for the jQuery plugin. * @param {Boolean} [noConflict] * Flag indicating whether or not to create a ".noConflict()" helper method * for the plugin. */ Bootstrap.pluginNoConflict = function (id, plugin, noConflict) { if (plugin.noConflict === void 0 && (noConflict === void 0 || noConflict)) { var old = $.fn[id]; plugin.noConflict = function () { $.fn[id] = old; return this; }; } }; /** * Replaces a Bootstrap jQuery plugin definition. * * @param {String} id * A jQuery plugin identifier located in $.fn. * @param {Function} callback * A callback function that is immediately invoked and must return a * function that will be used as the plugin constructor. * @param {Boolean} [noConflict] * Flag indicating whether or not to create a ".noConflict()" helper method * for the plugin. */ Bootstrap.replacePlugin = function (id, callback, noConflict) { // Immediately return if plugin doesn't exist. if (typeof $.fn[id] !== 'function') { return this.fatal('Specified jQuery plugin identifier does not exist: @id', {'@id': id}); } // Immediately return if callback isn't a function. if (typeof callback !== 'function') { return this.fatal('You must provide a valid callback function to replace a jQuery plugin: @callback', {'@callback': callback}); } // Determine existing plugin constructor. var constructor = $.fn[id] && $.fn[id].Constructor || $.fn[id]; var plugin = callback.apply(constructor, [this.settings]); // Immediately return if plugin isn't a function. if (typeof plugin !== 'function') { return this.fatal('Returned value from callback is not a usable function to replace a jQuery plugin "@id": @plugin', {'@id': id, '@plugin': plugin}); } this.wrapPluginConstructor(constructor, plugin); // Add a ".noConflict()" helper method. this.pluginNoConflict(id, plugin, noConflict); $.fn[id] = plugin; }; /** * Simulates a native event on an element in the browser. * * Note: This is a fairly complete modern implementation. If things aren't * working quite the way you intend (in older browsers), you may wish to use * the jQuery.simulate plugin. If it's available, this method will defer to * that plugin. * * @see https://github.com/jquery/jquery-simulate * * @param {HTMLElement|jQuery} element * A DOM element to dispatch event on. Note: this may be a jQuery object, * however be aware that this will trigger the same event for each element * inside the jQuery collection; use with caution. * @param {String|String[]} type * The type(s) of event to simulate. * @param {Object} [options] * An object of options to pass to the event constructor. Typically, if * an event is being proxied, you should just pass the original event * object here. This allows, if the browser supports it, to be a truly * simulated event. * * @return {Boolean} * The return value is false if event is cancelable and at least one of the * event handlers which handled this event called Event.preventDefault(). * Otherwise it returns true. */ Bootstrap.simulate = function (element, type, options) { // Handle jQuery object wrappers so it triggers on each element. var ret = true; if (element instanceof $) { element.each(function () { if (!Bootstrap.simulate(this, type, options)) { ret = false; } }); return ret; } if (!(element instanceof HTMLElement)) { this.fatal('Passed element must be an instance of HTMLElement, got "@type" instead.', { '@type': typeof element, }); } // Defer to the jQuery.simulate plugin, if it's available. if (typeof $.simulate === 'function') { new $.simulate(element, type, options); return true; } var event; var ctor; var types = [].concat(type); for (var i = 0, l = types.length; i < l; i++) { type = types[i]; for (var name in this.eventMap) { if (this.eventMap[name].test(type)) { ctor = name; break; } } if (!ctor) { throw new SyntaxError('Only rudimentary HTMLEvents, KeyboardEvents and MouseEvents are supported: ' + type); } var opts = {bubbles: true, cancelable: true}; if (ctor === 'KeyboardEvent' || ctor === 'MouseEvent') { $.extend(opts, {ctrlKey: !1, altKey: !1, shiftKey: !1, metaKey: !1}); } if (ctor === 'MouseEvent') { $.extend(opts, {button: 0, pointerX: 0, pointerY: 0, view: window}); } if (options) { $.extend(opts, options); } if (typeof window[ctor] === 'function') { event = new window[ctor](type, opts); if (!element.dispatchEvent(event)) { ret = false; } } else if (document.createEvent) { event = document.createEvent(ctor); event.initEvent(type, opts.bubbles, opts.cancelable); if (!element.dispatchEvent(event)) { ret = false; } } else if (typeof element.fireEvent === 'function') { event = $.extend(document.createEventObject(), opts); if (!element.fireEvent('on' + type, event)) { ret = false; } } else if (typeof element[type]) { element[type](); } } return ret; }; /** * Strips HTML and returns just text. * * @param {String|Element|jQuery} html * A string of HTML content, an Element DOM object or a jQuery object. * * @return {String} * The text without HTML tags. * * @todo Replace with http://locutus.io/php/strings/strip_tags/ */ Bootstrap.stripHtml = function (html) { if (html instanceof $) { html = html.html(); } else if (html instanceof Element) { html = html.innerHTML; } var tmp = document.createElement('DIV'); tmp.innerHTML = html; return (tmp.textContent || tmp.innerText || '').replace(/^[\s\n\t]*|[\s\n\t]*$/, ''); }; /** * Provide a helper method for displaying when something is unsupported. * * @param {String} type * The type of unsupported object, e.g. method or option. * @param {String} name * The name of the unsupported object. * @param {*} [value] * The value of the unsupported object. */ Bootstrap.unsupported = function (type, name, value) { Bootstrap.warn('Unsupported by Drupal Bootstrap: (@type) @name -> @value', { '@type': type, '@name': name, '@value': typeof value === 'object' ? JSON.stringify(value) : value }); }; /** * Provide a helper method to display a warning. * * @param {String} message * The message to display. * @param {Object} [args] * Arguments to use as replacements in Drupal.formatString. */ Bootstrap.warn = function (message, args) { if (this.settings.dev && console.warn) { console.warn(Drupal.formatString(message, args)); } }; /** * Wraps a plugin with common functionality. * * @param {Function} constructor * A plugin constructor being wrapped. * @param {Object|Function} plugin * The plugin being wrapped. * @param {Boolean} [extend = false] * Whether to add super extensibility. */ Bootstrap.wrapPluginConstructor = function (constructor, plugin, extend) { var proto = constructor.prototype; // Add a jQuery UI like option getter/setter method. var option = this.option; if (proto.option === void(0)) { proto.option = function () { return option.apply(this, arguments); }; } if (extend) { // Handle prototype properties separately. if (plugin.prototype !== void 0) { for (var key in plugin.prototype) { if (!plugin.prototype.hasOwnProperty(key)) continue; var value = plugin.prototype[key]; if (typeof value === 'function') { proto[key] = this.superWrapper(proto[key] || function () {}, value); } else { proto[key] = $.isPlainObject(value) ? $.extend(true, {}, proto[key], value) : value; } } } delete plugin.prototype; // Handle static properties. for (key in plugin) { if (!plugin.hasOwnProperty(key)) continue; value = plugin[key]; if (typeof value === 'function') { constructor[key] = this.superWrapper(constructor[key] || function () {}, value); } else { constructor[key] = $.isPlainObject(value) ? $.extend(true, {}, constructor[key], value) : value; } } } }; /** * Add Bootstrap to the global Drupal object. * * @type {Bootstrap} */ Drupal.bootstrap = Drupal.bootstrap || Bootstrap; })(window._, window.jQuery, window.Drupal, window.drupalSettings); ; (function ($, _) { /** * @class Attributes * * Modifies attributes. * * @param {Object|Attributes} attributes * An object to initialize attributes with. */ var Attributes = function (attributes) { this.data = {}; this.data['class'] = []; this.merge(attributes); }; /** * Renders the attributes object as a string to inject into an HTML element. * * @return {String} * A rendered string suitable for inclusion in HTML markup. */ Attributes.prototype.toString = function () { var output = ''; var name, value; var checkPlain = function (str) { return str && str.toString().replace(/&/g, '&').replace(/"/g, '"').replace(//g, '>') || ''; }; var data = this.getData(); for (name in data) { if (!data.hasOwnProperty(name)) continue; value = data[name]; if (_.isFunction(value)) value = value(); if (_.isObject(value)) value = _.values(value); if (_.isArray(value)) value = value.join(' '); output += ' ' + checkPlain(name) + '="' + checkPlain(value) + '"'; } return output; }; /** * Renders the Attributes object as a plain object. * * @return {Object} * A plain object suitable for inclusion in DOM elements. */ Attributes.prototype.toPlainObject = function () { var object = {}; var name, value; var data = this.getData(); for (name in data) { if (!data.hasOwnProperty(name)) continue; value = data[name]; if (_.isFunction(value)) value = value(); if (_.isObject(value)) value = _.values(value); if (_.isArray(value)) value = value.join(' '); object[name] = value; } return object; }; /** * Add class(es) to the array. * * @param {string|Array} value * An individual class or an array of classes to add. * * @return {Attributes} * * @chainable */ Attributes.prototype.addClass = function (value) { var args = Array.prototype.slice.call(arguments); this.data['class'] = this.sanitizeClasses(this.data['class'].concat(args)); return this; }; /** * Returns whether the requested attribute exists. * * @param {string} name * An attribute name to check. * * @return {boolean} * TRUE or FALSE */ Attributes.prototype.exists = function (name) { return this.data[name] !== void(0) && this.data[name] !== null; }; /** * Retrieve a specific attribute from the array. * * @param {string} name * The specific attribute to retrieve. * @param {*} defaultValue * (optional) The default value to set if the attribute does not exist. * * @return {*} * A specific attribute value, passed by reference. */ Attributes.prototype.get = function (name, defaultValue) { if (!this.exists(name)) this.data[name] = defaultValue; return this.data[name]; }; /** * Retrieves a cloned copy of the internal attributes data object. * * @return {Object} */ Attributes.prototype.getData = function () { return _.extend({}, this.data); }; /** * Retrieves classes from the array. * * @return {Array} * The classes array. */ Attributes.prototype.getClasses = function () { return this.get('class', []); }; /** * Indicates whether a class is present in the array. * * @param {string|Array} className * The class(es) to search for. * * @return {boolean} * TRUE or FALSE */ Attributes.prototype.hasClass = function (className) { className = this.sanitizeClasses(Array.prototype.slice.call(arguments)); var classes = this.getClasses(); for (var i = 0, l = className.length; i < l; i++) { // If one of the classes fails, immediately return false. if (_.indexOf(classes, className[i]) === -1) { return false; } } return true; }; /** * Merges multiple values into the array. * * @param {Attributes|Node|jQuery|Object} object * An Attributes object with existing data, a Node DOM element, a jQuery * instance or a plain object where the key is the attribute name and the * value is the attribute value. * @param {boolean} [recursive] * Flag determining whether or not to recursively merge key/value pairs. * * @return {Attributes} * * @chainable */ Attributes.prototype.merge = function (object, recursive) { // Immediately return if there is nothing to merge. if (!object) { return this; } // Get attributes from a jQuery element. if (object instanceof $) { object = object[0]; } // Get attributes from a DOM element. if (object instanceof Node) { object = Array.prototype.slice.call(object.attributes).reduce(function (attributes, attribute) { attributes[attribute.name] = attribute.value; return attributes; }, {}); } // Get attributes from an Attributes instance. else if (object instanceof Attributes) { object = object.getData(); } // Otherwise, clone the object. else { object = _.extend({}, object); } // By this point, there should be a valid plain object. if (!$.isPlainObject(object)) { setTimeout(function () { throw new Error('Passed object is not supported: ' + object); }); return this; } // Handle classes separately. if (object && object['class'] !== void 0) { this.addClass(object['class']); delete object['class']; } if (recursive === void 0 || recursive) { this.data = $.extend(true, {}, this.data, object); } else { this.data = $.extend({}, this.data, object); } return this; }; /** * Removes an attribute from the array. * * @param {string} name * The name of the attribute to remove. * * @return {Attributes} * * @chainable */ Attributes.prototype.remove = function (name) { if (this.exists(name)) delete this.data[name]; return this; }; /** * Removes a class from the attributes array. * * @param {...string|Array} className * An individual class or an array of classes to remove. * * @return {Attributes} * * @chainable */ Attributes.prototype.removeClass = function (className) { var remove = this.sanitizeClasses(Array.prototype.slice.apply(arguments)); this.data['class'] = _.without(this.getClasses(), remove); return this; }; /** * Replaces a class in the attributes array. * * @param {string} oldValue * The old class to remove. * @param {string} newValue * The new class. It will not be added if the old class does not exist. * * @return {Attributes} * * @chainable */ Attributes.prototype.replaceClass = function (oldValue, newValue) { var classes = this.getClasses(); var i = _.indexOf(this.sanitizeClasses(oldValue), classes); if (i >= 0) { classes[i] = newValue; this.set('class', classes); } return this; }; /** * Ensures classes are flattened into a single is an array and sanitized. * * @param {...String|Array} classes * The class or classes to sanitize. * * @return {Array} * A sanitized array of classes. */ Attributes.prototype.sanitizeClasses = function (classes) { return _.chain(Array.prototype.slice.call(arguments)) // Flatten in case there's a mix of strings and arrays. .flatten() // Split classes that may have been added with a space as a separator. .map(function (string) { return string.split(' '); }) // Flatten again since it was just split into arrays. .flatten() // Filter out empty items. .filter() // Clean the class to ensure it's a valid class name. .map(function (value) { return Attributes.cleanClass(value); }) // Ensure classes are unique. .uniq() // Retrieve the final value. .value(); }; /** * Sets an attribute on the array. * * @param {string} name * The name of the attribute to set. * @param {*} value * The value of the attribute to set. * * @return {Attributes} * * @chainable */ Attributes.prototype.set = function (name, value) { var obj = $.isPlainObject(name) ? name : {}; if (typeof name === 'string') { obj[name] = value; } return this.merge(obj); }; /** * Prepares a string for use as a CSS identifier (element, class, or ID name). * * Note: this is essentially a direct copy from * \Drupal\Component\Utility\Html::cleanCssIdentifier * * @param {string} identifier * The identifier to clean. * @param {Object} [filter] * An object of string replacements to use on the identifier. * * @return {string} * The cleaned identifier. */ Attributes.cleanClass = function (identifier, filter) { filter = filter || { ' ': '-', '_': '-', '/': '-', '[': '-', ']': '' }; identifier = identifier.toLowerCase(); if (filter['__'] === void 0) { identifier = identifier.replace('__', '#DOUBLE_UNDERSCORE#'); } identifier = identifier.replace(Object.keys(filter), Object.keys(filter).map(function(key) { return filter[key]; })); if (filter['__'] === void 0) { identifier = identifier.replace('#DOUBLE_UNDERSCORE#', '__'); } identifier = identifier.replace(/[^\u002D\u0030-\u0039\u0041-\u005A\u005F\u0061-\u007A\u00A1-\uFFFF]/g, ''); identifier = identifier.replace(['/^[0-9]/', '/^(-[0-9])|^(--)/'], ['_', '__']); return identifier; }; /** * Creates an Attributes instance. * * @param {object|Attributes} [attributes] * An object to initialize attributes with. * * @return {Attributes} * An Attributes instance. * * @constructor */ Attributes.create = function (attributes) { return new Attributes(attributes); }; window.Attributes = Attributes; })(window.jQuery, window._); ; /** * @file * Theme hooks for the Drupal Bootstrap base theme. */ (function ($, Drupal, Bootstrap, Attributes) { /** * Fallback for theming an icon if the Icon API module is not installed. */ if (!Drupal.icon) Drupal.icon = { bundles: {} }; if (!Drupal.theme.icon || Drupal.theme.prototype.icon) { $.extend(Drupal.theme, /** @lends Drupal.theme */ { /** * Renders an icon. * * @param {string} bundle * The bundle which the icon belongs to. * @param {string} icon * The name of the icon to render. * @param {object|Attributes} [attributes] * An object of attributes to also apply to the icon. * * @returns {string} */ icon: function (bundle, icon, attributes) { if (!Drupal.icon.bundles[bundle]) return ''; attributes = Attributes.create(attributes).addClass('icon').set('aria-hidden', 'true'); icon = Drupal.icon.bundles[bundle](icon, attributes); return ''; } }); } /** * Callback for modifying an icon in the "bootstrap" icon bundle. * * @param {string} icon * The icon being rendered. * @param {Attributes} attributes * Attributes object for the icon. */ Drupal.icon.bundles.bootstrap = function (icon, attributes) { attributes.addClass(['glyphicon', 'glyphicon-' + icon]); }; /** * Add necessary theming hooks. */ $.extend(Drupal.theme, /** @lends Drupal.theme */ { /** * Renders a Bootstrap AJAX glyphicon throbber. * * @returns {string} */ ajaxThrobber: function () { return Drupal.theme('bootstrapIcon', 'refresh', {'class': ['ajax-throbber', 'glyphicon-spin'] }); }, /** * Renders a button element. * * @param {object|Attributes} attributes * An object of attributes to apply to the button. If it contains one of: * - value: The label of the button. * - context: The context type of Bootstrap button, can be one of: * - default * - primary * - success * - info * - warning * - danger * - link * * @returns {string} */ button: function (attributes) { attributes = Attributes.create(attributes).addClass('btn'); var context = attributes.get('context', 'default'); var label = attributes.get('value', ''); attributes.remove('context').remove('value'); if (!attributes.hasClass(['btn-default', 'btn-primary', 'btn-success', 'btn-info', 'btn-warning', 'btn-danger', 'btn-link'])) { attributes.addClass('btn-' + Bootstrap.checkPlain(context)); } // Attempt to, intelligently, provide a default button "type". if (!attributes.exists('type')) { attributes.set('type', attributes.hasClass('form-submit') ? 'submit' : 'button'); } return '' + label + ''; }, /** * Alias for "button" theme hook. * * @param {object|Attributes} attributes * An object of attributes to apply to the button. * * @see Drupal.theme.button() * * @returns {string} */ btn: function (attributes) { return Drupal.theme('button', attributes); }, /** * Renders a button block element. * * @param {object|Attributes} attributes * An object of attributes to apply to the button. * * @see Drupal.theme.button() * * @returns {string} */ 'btn-block': function (attributes) { return Drupal.theme('button', Attributes.create(attributes).addClass('btn-block')); }, /** * Renders a large button element. * * @param {object|Attributes} attributes * An object of attributes to apply to the button. * * @see Drupal.theme.button() * * @returns {string} */ 'btn-lg': function (attributes) { return Drupal.theme('button', Attributes.create(attributes).addClass('btn-lg')); }, /** * Renders a small button element. * * @param {object|Attributes} attributes * An object of attributes to apply to the button. * * @see Drupal.theme.button() * * @returns {string} */ 'btn-sm': function (attributes) { return Drupal.theme('button', Attributes.create(attributes).addClass('btn-sm')); }, /** * Renders an extra small button element. * * @param {object|Attributes} attributes * An object of attributes to apply to the button. * * @see Drupal.theme.button() * * @returns {string} */ 'btn-xs': function (attributes) { return Drupal.theme('button', Attributes.create(attributes).addClass('btn-xs')); }, /** * Renders a glyphicon. * * @param {string} name * The name of the glyphicon. * @param {object|Attributes} [attributes] * An object of attributes to apply to the icon. * * @returns {string} */ bootstrapIcon: function (name, attributes) { return Drupal.theme('icon', 'bootstrap', name, attributes); } }); })(window.jQuery, window.Drupal, window.Drupal.bootstrap, window.Attributes); ; !function(t,a,e){"use strict";a.extlink=a.extlink||{},a.extlink.attach=function(e,n){if(n.data.hasOwnProperty("extlink")){var l,i=/^(([^\/:]+?\.)*)([^\.:]{4,})((\.[a-z]{1,4})*)(:[0-9]{1,5})?$/,s=window.location.host.replace(i,"$3$4"),x=window.location.host.replace(i,"$1");l=n.data.extlink.extSubdomains?"([^/]*\\.)?":"www."===x||""===x?"(www\\.)?":x.replace(".","\\.");var p=new RegExp("^https?://"+l+s,"i"),d=!1;n.data.extlink.extInclude&&(d=new RegExp(n.data.extlink.extInclude.replace(/\\/,"\\"),"i"));var r=!1;n.data.extlink.extExclude&&(r=new RegExp(n.data.extlink.extExclude.replace(/\\/,"\\"),"i"));var k=!1;n.data.extlink.extCssExclude&&(k=n.data.extlink.extCssExclude);var c=!1;n.data.extlink.extCssExplicit&&(c=n.data.extlink.extCssExplicit);var o=[],h=[];t("a:not(."+n.data.extlink.extClass+", ."+n.data.extlink.mailtoClass+"), area:not(."+n.data.extlink.extClass+", ."+n.data.extlink.mailtoClass+")",e).each(function(a){try{var e=this.href.toLowerCase();0!==e.indexOf("http")||(e.match(p)||r&&e.match(r))&&(!d||!e.match(d))||k&&t(this).parents(k).length>0||c&&t(this).parents(c).length<1?"AREA"===this.tagName||0!==e.indexOf("mailto:")||k&&t(this).parents(k).length>0||c&&t(this).parents(c).length<1||h.push(this):o.push(this)}catch(n){return!1}}),n.data.extlink.extClass&&a.extlink.applyClassAndSpan(o,n.data.extlink.extClass),n.data.extlink.mailtoClass&&a.extlink.applyClassAndSpan(h,n.data.extlink.mailtoClass),n.data.extlink.extTarget&&n.data.extlink.extTarget&&t(o).attr({target:'_blank', rel:'nofollow'}),a.extlink=a.extlink||{},a.extlink.popupClickHandler=a.extlink.popupClickHandler||function(){return n.data.extlink.extAlert?confirm(n.data.extlink.extAlertText):void 0},t(o).click(function(t){return a.extlink.popupClickHandler(t)})}},a.extlink.applyClassAndSpan=function(a,n){var l;if(e.data.extlink.extImgClass)l=t(a);else{var i=t(a).find("img").parents("a");l=t(a).not(i)}l.addClass(n);var s,x=l.length;for(s=0;x>s;s++){var p=t(l[s]);("inline"===p.css("display")||"inline-block"===p.css("display"))&&(n===e.data.extlink.mailtoClass?p.append(' '+e.data.extlink.mailtoLabel+""):p.append(' '+e.data.extlink.extLabel+""))}},a.behaviors.extlink=a.behaviors.extlink||{},a.behaviors.extlink.attach=function(t,e){"function"==typeof extlinkAttach?extlinkAttach(t):a.extlink.attach(t,e)}}(jQuery,Drupal,drupalSettings); ; /** * @file * Bootstrap Popovers. */ var Drupal = Drupal || {}; (function ($, Drupal, Bootstrap) { "use strict"; var $document = $(document); /** * Extend the Bootstrap Popover plugin constructor class. */ Bootstrap.extendPlugin('popover', function (settings) { return { DEFAULTS: { animation: !!settings.popover_animation, autoClose: !!settings.popover_auto_close, enabled: settings.popover_enabled, html: !!settings.popover_html, placement: settings.popover_placement, selector: settings.popover_selector, trigger: settings.popover_trigger, title: settings.popover_title, content: settings.popover_content, delay: parseInt(settings.popover_delay, 10), container: settings.popover_container } }; }); /** * Bootstrap Popovers. * * @todo This should really be properly delegated if selector option is set. */ Drupal.behaviors.bootstrapPopovers = { $activePopover: null, attach: function (context) { // Immediately return if popovers are not available. if (!$.fn.popover || !$.fn.popover.Constructor.DEFAULTS.enabled) { return; } var _this = this; $document .on('show.bs.popover', '[data-toggle=popover]', function () { var $trigger = $(this); var popover = $trigger.data('bs.popover'); // Only keep track of clicked triggers that we're manually handling. if (popover.options.originalTrigger === 'click') { if (_this.$activePopover && _this.getOption('autoClose') && !_this.$activePopover.is($trigger)) { _this.$activePopover.popover('hide'); } _this.$activePopover = $trigger; } }) // Unfortunately, :focusable is only made available when using jQuery // UI. While this would be the most semantic pseudo selector to use // here, jQuery UI may not always be loaded. Instead, just use :visible // here as this just needs some sort of selector here. This activates // delegate binding to elements in jQuery so it can work it's bubbling // focus magic since elements don't really propagate their focus events. // @see https://www.drupal.org/project/bootstrap/issues/3013236 .on('focus.bs.popover', ':visible', function (e) { var $target = $(e.target); if (_this.$activePopover && _this.getOption('autoClose') && !_this.$activePopover.is($target) && !$target.closest('.popover.in')[0]) { _this.$activePopover.popover('hide'); _this.$activePopover = null; } }) .on('click.bs.popover', function (e) { var $target = $(e.target); if (_this.$activePopover && _this.getOption('autoClose') && !$target.is('[data-toggle=popover]') && !$target.closest('.popover.in')[0]) { _this.$activePopover.popover('hide'); _this.$activePopover = null; } }) .on('keyup.bs.popover', function (e) { if (_this.$activePopover && _this.getOption('autoClose') && e.which === 27) { _this.$activePopover.popover('hide'); _this.$activePopover = null; } }) ; var elements = $(context).find('[data-toggle=popover]').toArray(); for (var i = 0; i < elements.length; i++) { var $element = $(elements[i]); var options = $.extend({}, $.fn.popover.Constructor.DEFAULTS, $element.data()); // Store the original trigger. options.originalTrigger = options.trigger; // If the trigger is "click", then we'll handle it manually here. if (options.trigger === 'click') { options.trigger = 'manual'; } // Retrieve content from a target element. var target = options.target || $element.is('a[href^="#"]') && $element.attr('href'); var $target = $document.find(target).clone(); if (!options.content && $target[0]) { $target.removeClass('visually-hidden hidden').removeAttr('aria-hidden'); options.content = $target.wrap('
').parent()[options.html ? 'html' : 'text']() || ''; } // Initialize the popover. $element.popover(options); // Handle clicks manually. if (options.originalTrigger === 'click') { // To ensure the element is bound multiple times, remove any // previously set event handler before adding another one. $element .off('click.drupal.bootstrap.popover') .on('click.drupal.bootstrap.popover', function (e) { $(this).popover('toggle'); e.preventDefault(); e.stopPropagation(); }) ; } } }, detach: function (context) { // Immediately return if popovers are not available. if (!$.fn.popover || !$.fn.popover.Constructor.DEFAULTS.enabled) { return; } // Destroy all popovers. $(context).find('[data-toggle="popover"]') .off('click.drupal.bootstrap.popover') .popover('destroy') ; }, getOption: function(name, defaultValue, element) { var $element = element ? $(element) : this.$activePopover; var options = $.extend(true, {}, $.fn.popover.Constructor.DEFAULTS, ($element && $element.data('bs.popover') || {}).options); if (options[name] !== void 0) { return options[name]; } return defaultValue !== void 0 ? defaultValue : void 0; } }; })(window.jQuery, window.Drupal, window.Drupal.bootstrap); ; /** * @file * Bootstrap Tooltips. */ var Drupal = Drupal || {}; (function ($, Drupal, Bootstrap) { "use strict"; /** * Extend the Bootstrap Tooltip plugin constructor class. */ Bootstrap.extendPlugin('tooltip', function (settings) { return { DEFAULTS: { animation: !!settings.tooltip_animation, html: !!settings.tooltip_html, placement: settings.tooltip_placement, selector: settings.tooltip_selector, trigger: settings.tooltip_trigger, delay: parseInt(settings.tooltip_delay, 10), container: settings.tooltip_container } }; }); /** * Bootstrap Tooltips. * * @todo This should really be properly delegated if selector option is set. */ Drupal.behaviors.bootstrapTooltips = { attach: function (context) { var elements = $(context).find('[data-toggle="tooltip"]').toArray(); for (var i = 0; i < elements.length; i++) { var $element = $(elements[i]); var options = $.extend({}, $.fn.tooltip.Constructor.DEFAULTS, $element.data()); $element.tooltip(options); } }, detach: function (context) { // Destroy all tooltips. $(context).find('[data-toggle="tooltip"]').tooltip('destroy'); } }; })(window.jQuery, window.Drupal, window.Drupal.bootstrap); ; (function ($) { Drupal.behaviors.CeleparMenuColuna = { attach: function(context, settings) { $('#btn-mobile-menu', context).once('celepar-menu-mobile').click(function (e) { if ($(this).hasClass('active')) { $(this).removeClass('active'); $('#wrapper').width($(window).width()); $('#top-navigation').animate({ left: -300 }, 200, function () { $('#wrapper').animate({ marginLeft: 0 }, 500); $('.mobile-menu-overlay').animate({ marginLeft: 0 }, 500); }); $('.mobile-menu-overlay').hide(); $(this).find('i.fas').removeClass('fa-arrow-left').addClass('fa-bars'); $('.bg-menu-mobile').hide(); $('#top-navigation').css('box-shadow', 'none'); } else { $(this).addClass('active'); $('#wrapper').width($(window).width()); $('#top-navigation').animate({ left: 0 }, 200, function () { $('#wrapper').animate({ marginLeft: 300 }, 500); $('.mobile-menu-overlay').animate({ marginLeft: 300 }, 500); }); $('.mobile-menu-overlay').show().height($(document).height()); $(this).find('i.fas').removeClass('fa-bars').addClass('fa-arrow-left'); $('.bg-menu-mobile').show(); $('#top-navigation').css('box-shadow', '0px 0px 10px 0px rgba(0,0,0,0.75)'); } }); } }; $(document).ready(function () { // adicionar icone quando tem submenu $('ul.mn-navegacao li').each(function (index, el) { if ($(this).parent().parent().attr('id') != 'block-footer-menu') { //não coloca seta no 1º nível do menu do rodapé if ($(this).find('ul').length > 0) { //$(this).children('a').addClass('item-pai').attr('aria-haspopup', 'true').attr('aria-expanded', 'false'); //Alterações de acessibilidade if ($(this).parent('.mn-navegacao').length == 0) { // se for no menu principal, em colunas $(this).children('a').find('span').first().append(''); } else { $(this).children('a').find('span').first().append(''); } } } }); //fecha o menu superior ao clicar fora $('html').click(function (event) { $('#top-navigation ul.mn-navegacao li').removeClass('active'); $('#top-navigation ul.mn-navegacao li a .fa-caret-up').removeClass('fa-caret-up').addClass('fa-caret-down'); }); $('.mn-navegacao').click(function (event) { event.stopPropagation(); }); //ao clicar em um item $('ul.mn-navegacao li a').click(function (event) { if ($(this).parent().children('ul').length > 0) { event.preventDefault(); $(this).parent('li').children('.sub-mn-navegacao').css('overflow-y', 'hidden'); } if ($(this).parent().hasClass('active')) { //fecha o item menu $('ul.mn-navegacao li .sub-mn-navegacao').css('overflow', 'hidden'); //remove scroll de todos // ADD $(this).parent().removeClass('active'); if ($(this).find('span').children('.fa-caret-up').length > 0) { $(this).find('span').children('.fa-caret-up').removeClass('fa-caret-up').addClass('fa-caret-down'); } $(this).attr('aria-expanded', 'false'); // Acessibilidade / indicar que o submenu está fechado Alterações de acessibilidade $(this).parent().children('.sub-mn-navegacao').attr('aria-hidden','true'); //Alterações de acessibilidade $(this).parent().children('.sub-mn-navegacao').css('visibility','hidden'); //Alterações de acessibilidade } else { //abre o item menu $(this).parent().children('.sub-mn-navegacao').attr('aria-hidden','false'); //Alterações de acessibilidade $(this).parent().children('.sub-mn-navegacao').css('visibility','visible'); //Alterações de acessibilidade $('ul.mn-navegacao li .fa-caret-up').removeClass('fa-caret-up').addClass('fa-caret-down'); if ($(this).parent().parent('.mn-navegacao').length > 0) { //primeiro nível $('ul.mn-navegacao li').removeClass('active'); $('ul.mn-navegacao li .sub-mn-navegacao').css('overflow', 'hidden'); //remove scroll de todos // ADD } else { //demais níveis if ($(this).closest("ul").parent().index() == 4) { //segundo nível $('ul.mn-navegacao li ul li').removeClass('active'); } else if ($(this).closest("ul").parent().index() == 5) { //terceiro nível $('ul.mn-navegacao li ul ul li').removeClass('active'); } } $(this).parent().addClass('active'); if ($(this).find('span').children('.fa-caret-down').length > 0) { $(this).find('span').children('.fa-caret-down').removeClass('fa-caret-down').addClass('fa-caret-up'); } //insere scroll se tiver muitos itens parentLi = $(this).parent('li'); if (parentLi.children('.sub-mn-navegacao').length > 0) { //se tiver submenu parentLi.parents('.sub-mn-navegacao').css('overflow-y', 'hidden'); //remove o scroll dos pais if (parentLi.children('.sub-mn-navegacao').children('.menu-column').children('li').length > 50) { parentLi.children('.sub-mn-navegacao').css('overflow-y', 'auto'); } } //se excedeu a altura parentLi.children('.sub-mn-navegacao').on('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend', function(event) { if($(this).children('.menu-column').height()>320) { $(this).css('overflow-y', 'auto'); } }); //se o submenu estourou para direita subMenu = $(this).parent('li').find('.sub-mn-navegacao'); if (($(document).width() > 767) && (subMenu.children('ul').hasClass('num-cols-1') || subMenu.children('ul').hasClass('num-cols-2')) && (subMenu.closest('.sub-mn-navegacao').length <= 1)) { container_right = Math.ceil($(this).parents('.container').offset().left + $(this).parents('.container').width() + 30); menu_right = Math.ceil($(this).parent('li').offset().left+subMenu.width()); if (container_right < menu_right) { // $(this).parent('li').children('.sub-mn-navegacao').css({'margin-left':(container_right-menu_right)+'px'}); } } $(this).attr('aria-expanded', 'true'); // Acessibilidade / indicar que o submenu está aberto Alterações de acessibilidade } $(this).focus(); }); // Inicio - Ajuste para melhorar a exibição do menu para quando tiver muitos itens if($(window).width()>767) { stepAnim = 200; totalMenuWidth = 0; $('#block-main-menu > .mn-navegacao > li').each(function(index, el) { totalMenuWidth += $(this).width(); }); if(totalMenuWidth > $('#block-main-menu > .mn-navegacao').width()) { $('body').css({ width: '100%', 'overflow-x': 'hidden' }); $('#top-navigation .region-top-navigation').append(''); $('.menu-left-scroll').hide(); marginScroll = 0; $('.menu-right-scroll').click(function(event) { event.preventDefault(); $('.menu-left-scroll').show(); $('#block-main-menu').addClass('menu-scrolled-left'); lastMenuItem = $('#block-main-menu > .mn-navegacao > li:last-child'); menuRightPosition = lastMenuItem.position().left+lastMenuItem.find('a').width(); menuRightPosition = lastMenuItem.position().left+lastMenuItem.find('a').width()+stepAnim; blockMenuRightPosition = $('#block-main-menu').position().left+$('#block-main-menu').width(); if (menuRightPosition > blockMenuRightPosition) { marginScroll -= stepAnim; $('.menu-right-scroll').prop('disabled', true); $('#block-main-menu .mn-navegacao').css({ 'margin-left':marginScroll }).one('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend',function(e) { $('.menu-right-scroll').prop('disabled', false); }); if ((menuRightPosition-stepAnim) < blockMenuRightPosition) { $('.menu-right-scroll').hide(); } } }); $('.menu-left-scroll').click(function(event) { event.preventDefault(); $('.menu-right-scroll').show(); blockMenuLeftPosition = parseFloat($('#block-main-menu > .mn-navegacao').css('margin-left')); if (blockMenuLeftPosition <= 0) { marginScroll += stepAnim; $('.menu-left-scroll').prop('disabled', true); $('#block-main-menu .mn-navegacao').css({ 'margin-left':marginScroll }).one('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend',function(e) { $('.menu-left-scroll').prop('disabled', false); }); if (blockMenuLeftPosition >= -stepAnim) { $('.menu-left-scroll').hide(); $('#block-main-menu').removeClass('menu-scrolled-left'); } } }); } } // Fim - Ajuste para melhorar a exibição do menu para quando tiver muitos itens //menu mobile /* $('#btn-mobile-menu').click(function () { if ($(this).hasClass('active')) { $(this).removeClass('active'); $('#wrapper').width($(window).width()); $('#top-navigation').animate({ left: -300 }, 200, function () { $('#wrapper').animate({ marginLeft: 0 }, 500); $('.mobile-menu-overlay').animate({ marginLeft: 0 }, 500); }); $('.mobile-menu-overlay').hide(); $(this).find('i.fas').removeClass('fa-arrow-left').addClass('fa-bars'); $('.bg-menu-mobile').hide(); $('#top-navigation').css('box-shadow', 'none'); } else { $(this).addClass('active'); $('#wrapper').width($(window).width()); $('#top-navigation').animate({ left: 0 }, 200, function () { $('#wrapper').animate({ marginLeft: 300 }, 500); $('.mobile-menu-overlay').animate({ marginLeft: 300 }, 500); }); $('.mobile-menu-overlay').show().height($(document).height()); $(this).find('i.fas').removeClass('fa-bars').addClass('fa-arrow-left'); $('.bg-menu-mobile').show(); $('#top-navigation').css('box-shadow', '0px 0px 10px 0px rgba(0,0,0,0.75)'); } }); */ //containerWidth(); $('#opt-site-map').click(function (event) { event.preventDefault(); $('#block-footer-menu').toggle(); }); // para não ocultar o menu no scroll mobile var lastWidth = $(window).width(); $(window).resize(function() { if($(window).width()!=lastWidth){ $('#wrapper').width('auto'); $('#wrapper').css('margin-left', '0'); /* fechar o menu mobile */ $('#btn-mobile-menu').removeClass('active'); $('#top-navigation').css('left','-300px'); $('#wrapper').css('margin-left','0'); $('.mobile-menu-overlay').css('margin-left','0').hide(); $('#btn-mobile-menu').find('i.fas').removeClass('fa-arrow-left').addClass('fa-bars'); $('.bg-menu-mobile').hide(); $('#top-navigation').css('box-shadow','none'); lastWidth = $(window).width(); } }); //menu mobile // fechar sempre que clicar em um item do menu Ancora. $('#main-navigation>a').click(function(){ if(!$(this).hasClass('item-pai')) { $('#btn-mobile-menu').removeClass('active'); $('#wrapper').width($(window).width()); $('#top-navigation').animate({ left: -300 }, 200, function () { $('#wrapper').animate({ marginLeft: 0 }, 500); $('.mobile-menu-overlay').animate({ marginLeft: 0 }, 500); }); $('.mobile-menu-overlay').hide(); $('#btn-mobile-menu').find('i.fas').removeClass('fa-arrow-left').addClass('fa-bars'); $('.bg-menu-mobile').hide(); $('#top-navigation').css('box-shadow', 'none'); } }); if ($(document).width() > 767) { // Monta o menu novo $('.sub-mn-navegacao').css('width', $('.container').width()); //distribuir os itens em colunas $('#block-main-menu ul.mn-navegacao li ul').each(function (index, el) { $(this).addClass('sub-mn-navegacao'); $(this).parent().children('a').addClass('item-pai').attr('aria-haspopup', 'true').attr('aria-expanded', 'false'); //Alterações de acessibilidade $(this).attr('aria-hidden','true'); //Alterações de acessibilidade $(this).css('visibility','hidden'); //Alterações de acessibilidade container = $(this); items = container.children('li'); listClass = 'menu-column'; parentLiPosition = Math.ceil($(this).parent('li').offset().left); //POSICAO DO ITEM PAI if (items.length <= 10) { num_cols = 1; width_cols = 250; if (($(this).parent('li').parent('.mn-navegacao').length == 1) && ($(this).find('ul').length == 0)) { //só segundo nível sem filho $(this).css('width',width_cols+'px'); $(this).parent().css('position', 'relative'); } } else if ((items.length > 10) && (items.length <= 20)) { num_cols = 2; if (($(this).parent('li').parent('.mn-navegacao').length == 1) && ($(this).find('ul').length == 0)) { //só segundo nível sem filho //se o submenu estourou para esquerda if ((parentLiPosition - 100) <= $(this).parents('.container').offset().left) { marginSubmenu = '0'; } else { marginSubmenu = '-100px'; } $(this).css({ 'width': '500px', 'margin-left':marginSubmenu }); $(this).parent().css('position', 'relative'); } } else if ((items.length > 20) && (items.length <= 30)) { num_cols = 3; } else if ((items.length > 30) && (items.length <= 40)) { num_cols = 4; } else if (items.length > 40) { num_cols = 5; } container.each(function () { var items_per_col = new Array([]); min_items_per_col = Math.floor(items.length / num_cols); difference = items.length - (min_items_per_col * num_cols); for (var i = 0; i < num_cols; i++) { if (i < difference) { items_per_col[i] = min_items_per_col + 1; } else { items_per_col[i] = min_items_per_col; } $(this).append($('
    ').addClass(listClass + ' num-cols-' + num_cols)); for (var j = 0; j < items_per_col[i]; j++) { var pointer = 0; for (var k = 0; k < i; k++) { pointer += items_per_col[k]; } $(this).find('.' + listClass).last().append(items[j + pointer]); } } }); }); //insere a barra com obtao voltar/fechar $('#block-main-menu ul.mn-navegacao li').each(function (index, el) { if ($(this).find('ul').length > 0) { if ($(this).parent('.mn-navegacao').length == 0) { //menos do primeiro nível $(this).children('ul').prepend(''); //adiciona o botão voltar no submenu //Alterações de acessibilidade 2 } } }); $('.btn-menu-back').click(function (event) { //voltar um nível parentLi = $(this).parent('.menu-back-bar').parent('.sub-mn-navegacao').parent('li'); parentLi.removeClass('active'); //insere scroll se tiver muitos itens if (parentLi.parent('.menu-column').parent('.sub-mn-navegacao').children('.menu-column').children('li').length > 50) { parentLi.parent('.menu-column').parent('.sub-mn-navegacao').css('overflow-y', 'auto'); } }); } parentLi.children('a.item-pai').attr('aria-haspopup', 'true').attr('aria-expanded', 'false').focus(); //Alterações de acessibilidade 2 }); })(jQuery); ; /** * DO NOT EDIT THIS FILE. * See the following change record for more information, * https://www.drupal.org/node/2815083 * @preserve **/ Drupal.debounce = function (func, wait, immediate) { var timeout = void 0; var result = void 0; return function () { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } var context = this; var later = function later() { timeout = null; if (!immediate) { result = func.apply(context, args); } }; var callNow = immediate && !timeout; clearTimeout(timeout); timeout = setTimeout(later, wait); if (callNow) { result = func.apply(context, args); } return result; }; };; !function(i,n,s){"use strict";function l(l,t){function e(i){if(g.find(".b-lazy:not(.b-loaded)").length){var s=g.find(i?".slide:not(.slick-cloned) .b-lazy:not(.b-loaded)":".slick-active .b-lazy:not(.b-loaded)");s.length||(s=g.find(".slick-cloned .b-lazy:not(.b-loaded)")),s.length&&n.blazy.init.load(s)}}function a(){b&&r(),y&&e(!1)}function o(n){var s=i(n),l=s.closest(".slide")||s.closest(".unslick");s.parentsUntil(l).removeClass(function(i,n){return(n.match(/(\S+)loading/g)||[]).join(" ")});var t=s.closest(".media--background");t.length&&t.find("> img").length&&(t.css("background-image","url("+s.attr("src")+")"),t.find("> img").remove(),t.removeAttr("data-lazy"))}function d(){g.children().sort(function(){return.5-Math.random()}).each(function(){g.append(this)})}function c(i){var n=i.slideCount<=i.options.slidesToShow,s=n||!1===i.options.arrows;if(g.attr("id")===i.$slider.attr("id")){i.options.centerPadding&&"0"!==i.options.centerPadding||i.$list.css("padding",""),n&&i.$slideTrack.width()<=i.$slider.width()&&i.$slideTrack.css({left:"",transform:""});var l=g.find(".b-loaded ~ .b-loader");l.length&&l.remove(),p[s?"addClass":"removeClass"]("visually-hidden")}}function r(){g.removeClass("is-paused"),g.find(".is-playing").length&&g.find(".is-playing").removeClass("is-playing").find(".media__icon--close").click()}function u(){g.addClass("is-paused").slick("slickPause")}function f(s){return _?{}:{slide:s.slide,lazyLoad:s.lazyLoad,dotsClass:s.dotsClass,rtl:s.rtl,prevArrow:i(".slick-prev",p),nextArrow:i(".slick-next",p),appendArrows:p,customPaging:function(i,l){var t=i.$slides.eq(l).find("[data-thumb]")||null,e=''+n.t(t.find(',a=t.length&&s.dotsClass.indexOf("thumbnail")>0?'
    '+e+"
    ":"",o=i.defaults.customPaging(i,l);return a?o.add(a):o}}}var k,g=i("> .slick__slider",t).length?i("> .slick__slider",t):i(t),p=i("> .slick__arrow",t),h=g.data("slick")?i.extend({},s.slick,g.data("slick")):i.extend({},s.slick),m=!("array"!==i.type(h.responsive)||!h.responsive.length)&&h.responsive,v=h.appendDots,y="blazy"===h.lazyLoad&&n.blazy,b=g.find(".media--player").length,_=g.hasClass("unslick");if(_||(h.appendDots=".slick__arrow"===v?p:v||i(g)),m)for(k in m)Object.prototype.hasOwnProperty.call(m,k)&&"unslick"!==m[k].settings&&(m[k].settings=i.extend({},s.slick,f(h),m[k].settings));g.data("slick",h),h=g.data("slick"),function(){h.randomize&&!g.hasClass("slick-initiliazed")&&d(),_||g.on("init.sl",function(s,l){".slick__arrow"===v&&i(l.$dots).insertAfter(l.$prevArrow);var t=g.find(".slick-cloned.slick-active .b-lazy:not(.b-loaded)");y&&t.length&&n.blazy.init.load(t)}),y?g.on("beforeChange.sl",function(){e(!0)}):i(".media",g).closest(".slide__content").addClass("is-loading"),g.on("setPosition.sl",function(i,n){c(n)})}(),g.slick(f(h)),function(){g.parent().on("click.sl",".slick-down",function(n){n.preventDefault();var s=i(this);i("html, body").stop().animate({scrollTop:i(s.data("target")).offset().top-(s.data("offset")||0)},800,"easeOutQuad"in i.easing&&h.easing?h.easing:"swing")}),h.mouseWheel&&g.on("mousewheel.sl",function(i,n){return i.preventDefault(),g.slick(n<0?"slickNext":"slickPrev")}),y||g.on("lazyLoaded lazyLoadError",function(i,n,s){o(s)}),g.on("afterChange.sl",a),b&&(g.on("click.sl",".media__icon--close",r),g.on("click.sl",".media__icon--play",u))}(),_&&g.slick("unslick"),i(t).addClass("slick--initialized")}n.behaviors.slick={attach:function(n){i(".slick",n).once("slick").each(l)}}}(jQuery,Drupal,drupalSettings); ; !function(a){Drupal.behaviors.RemoveRedesSociaisFooter={attach:function(o,t){a("footer#main-footer .footer-social",o).on("load",function(){a(this).css({display:"none"}),a("footer#main-footer .footer-logo-celepar").css({"margin-top":"0"})}).once("footerSocial").trigger("load")}}}(jQuery);; /*! * jQuery Form Plugin * version: 4.2.2 * Requires jQuery v1.7.2 or later * Project repository: https://github.com/jquery-form/form * Copyright 2017 Kevin Morris * Copyright 2006 M. Alsup * Dual licensed under the LGPL-2.1+ or MIT licenses * https://github.com/jquery-form/form#license * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ !function(e){"function"==typeof define&&define.amd?define(["jquery"],e):"object"==typeof module&&module.exports?module.exports=function(t,r){return void 0===r&&(r="undefined"!=typeof window?require("jquery"):require("jquery")(t)),e(r),r}:e(jQuery)}(function(e){"use strict";function t(t){var r=t.data;t.isDefaultPrevented()||(t.preventDefault(),e(t.target).closest("form").ajaxSubmit(r))}function r(t){var r=t.target,a=e(r);if(!a.is("[type=submit],[type=image]")){var n=a.closest("[type=submit]");if(0===n.length)return;r=n[0]}var i=r.form;if(i.clk=r,"image"===r.type)if(void 0!==t.offsetX)i.clk_x=t.offsetX,i.clk_y=t.offsetY;else if("function"==typeof e.fn.offset){var o=a.offset();i.clk_x=t.pageX-o.left,i.clk_y=t.pageY-o.top}else i.clk_x=t.pageX-r.offsetLeft,i.clk_y=t.pageY-r.offsetTop;setTimeout(function(){i.clk=i.clk_x=i.clk_y=null},100)}function a(){if(e.fn.ajaxSubmit.debug){var t="[jquery.form] "+Array.prototype.join.call(arguments,"");window.console&&window.console.log?window.console.log(t):window.opera&&window.opera.postError&&window.opera.postError(t)}}var n=/\r?\n/g,i={};i.fileapi=void 0!==e('').get(0).files,i.formdata=void 0!==window.FormData;var o=!!e.fn.prop;e.fn.attr2=function(){if(!o)return this.attr.apply(this,arguments);var e=this.prop.apply(this,arguments);return e&&e.jquery||"string"==typeof e?e:this.attr.apply(this,arguments)},e.fn.ajaxSubmit=function(t,r,n,s){function u(r){var a,n,i=e.param(r,t.traditional).split("&"),o=i.length,s=[];for(a=0;a',k).val(f.extraData[c].value).appendTo(w)[0]):u.push(e('',k).val(f.extraData[c]).appendTo(w)[0]));f.iframeTarget||h.appendTo(D),v.attachEvent?v.attachEvent("onload",s):v.addEventListener("load",s,!1),setTimeout(t,15);try{w.submit()}catch(e){document.createElement("form").submit.apply(w)}}finally{w.setAttribute("action",i),w.setAttribute("enctype",o),r?w.setAttribute("target",r):p.removeAttr("target"),e(u).remove()}}function s(t){if(!x.aborted&&!X){if((O=n(v))||(a("cannot access response document"),t=L),t===A&&x)return x.abort("timeout"),void S.reject(x,"timeout");if(t===L&&x)return x.abort("server abort"),void S.reject(x,"error","server abort");if(O&&O.location.href!==f.iframeSrc||T){v.detachEvent?v.detachEvent("onload",s):v.removeEventListener("load",s,!1);var r,i="success";try{if(T)throw"timeout";var o="xml"===f.dataType||O.XMLDocument||e.isXMLDoc(O);if(a("isXml="+o),!o&&window.opera&&(null===O.body||!O.body.innerHTML)&&--C)return a("requeing onLoad callback, DOM not available"),void setTimeout(s,250);var u=O.body?O.body:O.documentElement;x.responseText=u?u.innerHTML:null,x.responseXML=O.XMLDocument?O.XMLDocument:O,o&&(f.dataType="xml"),x.getResponseHeader=function(e){return{"content-type":f.dataType}[e.toLowerCase()]},u&&(x.status=Number(u.getAttribute("status"))||x.status,x.statusText=u.getAttribute("statusText")||x.statusText);var c=(f.dataType||"").toLowerCase(),l=/(json|script|text)/.test(c);if(l||f.textarea){var p=O.getElementsByTagName("textarea")[0];if(p)x.responseText=p.value,x.status=Number(p.getAttribute("status"))||x.status,x.statusText=p.getAttribute("statusText")||x.statusText;else if(l){var m=O.getElementsByTagName("pre")[0],g=O.getElementsByTagName("body")[0];m?x.responseText=m.textContent?m.textContent:m.innerText:g&&(x.responseText=g.textContent?g.textContent:g.innerText)}}else"xml"===c&&!x.responseXML&&x.responseText&&(x.responseXML=q(x.responseText));try{M=N(x,c,f)}catch(e){i="parsererror",x.error=r=e||i}}catch(e){a("error caught: ",e),i="error",x.error=r=e||i}x.aborted&&(a("upload aborted"),i=null),x.status&&(i=x.status>=200&&x.status<300||304===x.status?"success":"error"),"success"===i?(f.success&&f.success.call(f.context,M,"success",x),S.resolve(x.responseText,"success",x),d&&e.event.trigger("ajaxSuccess",[x,f])):i&&(void 0===r&&(r=x.statusText),f.error&&f.error.call(f.context,x,i,r),S.reject(x,"error",r),d&&e.event.trigger("ajaxError",[x,f,r])),d&&e.event.trigger("ajaxComplete",[x,f]),d&&!--e.active&&e.event.trigger("ajaxStop"),f.complete&&f.complete.call(f.context,x,i),X=!0,f.timeout&&clearTimeout(j),setTimeout(function(){f.iframeTarget?h.attr("src",f.iframeSrc):h.remove(),x.responseXML=null},100)}}}var u,c,f,d,m,h,v,x,y,b,T,j,w=p[0],S=e.Deferred();if(S.abort=function(e){x.abort(e)},r)for(c=0;c',k)).css({position:"absolute",top:"-1000px",left:"-1000px"}),v=h[0],x={aborted:0,responseText:null,responseXML:null,status:0,statusText:"n/a",getAllResponseHeaders:function(){},getResponseHeader:function(){},setRequestHeader:function(){},abort:function(t){var r="timeout"===t?"timeout":"aborted";a("aborting upload... "+r),this.aborted=1;try{v.contentWindow.document.execCommand&&v.contentWindow.document.execCommand("Stop")}catch(e){}h.attr("src",f.iframeSrc),x.error=r,f.error&&f.error.call(f.context,x,r,t),d&&e.event.trigger("ajaxError",[x,f,r]),f.complete&&f.complete.call(f.context,x,r)}},(d=f.global)&&0==e.active++&&e.event.trigger("ajaxStart"),d&&e.event.trigger("ajaxSend",[x,f]),f.beforeSend&&!1===f.beforeSend.call(f.context,x,f))return f.global&&e.active--,S.reject(),S;if(x.aborted)return S.reject(),S;(y=w.clk)&&(b=y.name)&&!y.disabled&&(f.extraData=f.extraData||{},f.extraData[b]=y.value,"image"===y.type&&(f.extraData[b+".x"]=w.clk_x,f.extraData[b+".y"]=w.clk_y));var A=1,L=2,F=e("meta[name=csrf-token]").attr("content"),E=e("meta[name=csrf-param]").attr("content");E&&F&&(f.extraData=f.extraData||{},f.extraData[E]=F),f.forceSync?i():setTimeout(i,10);var M,O,X,C=50,q=e.parseXML||function(e,t){return window.ActiveXObject?((t=new ActiveXObject("Microsoft.XMLDOM")).async="false",t.loadXML(e)):t=(new DOMParser).parseFromString(e,"text/xml"),t&&t.documentElement&&"parsererror"!==t.documentElement.nodeName?t:null},_=e.parseJSON||function(e){return window.eval("("+e+")")},N=function(t,r,a){var n=t.getResponseHeader("content-type")||"",i=("xml"===r||!r)&&n.indexOf("xml")>=0,o=i?t.responseXML:t.responseText;return i&&"parsererror"===o.documentElement.nodeName&&e.error&&e.error("parsererror"),a&&a.dataFilter&&(o=a.dataFilter(o,r)),"string"==typeof o&&(("json"===r||!r)&&n.indexOf("json")>=0?o=_(o):("script"===r||!r)&&n.indexOf("javascript")>=0&&e.globalEval(o)),o};return S}if(!this.length)return a("ajaxSubmit: skipping submit process - no element selected"),this;var l,f,d,p=this;"function"==typeof t?t={success:t}:"string"==typeof t||!1===t&&arguments.length>0?(t={url:t,data:r,dataType:n},"function"==typeof s&&(t.success=s)):void 0===t&&(t={}),l=t.method||t.type||this.attr2("method"),(d=(d="string"==typeof(f=t.url||this.attr2("action"))?e.trim(f):"")||window.location.href||"")&&(d=(d.match(/^([^#]+)/)||[])[1]),t=e.extend(!0,{url:d,success:e.ajaxSettings.success,type:l||e.ajaxSettings.type,iframeSrc:/^https/i.test(window.location.href||"")?"javascript:false":"about:blank"},t);var m={};if(this.trigger("form-pre-serialize",[this,t,m]),m.veto)return a("ajaxSubmit: submit vetoed via form-pre-serialize trigger"),this;if(t.beforeSerialize&&!1===t.beforeSerialize(this,t))return a("ajaxSubmit: submit aborted via beforeSerialize callback"),this;var h=t.traditional;void 0===h&&(h=e.ajaxSettings.traditional);var v,g=[],x=this.formToArray(t.semantic,g,t.filtering);if(t.data){var y=e.isFunction(t.data)?t.data(x):t.data;t.extraData=y,v=e.param(y,h)}if(t.beforeSubmit&&!1===t.beforeSubmit(x,this,t))return a("ajaxSubmit: submit aborted via beforeSubmit callback"),this;if(this.trigger("form-submit-validate",[x,this,t,m]),m.veto)return a("ajaxSubmit: submit vetoed via form-submit-validate trigger"),this;var b=e.param(x,h);v&&(b=b?b+"&"+v:v),"GET"===t.type.toUpperCase()?(t.url+=(t.url.indexOf("?")>=0?"&":"?")+b,t.data=null):t.data=b;var T=[];if(t.resetForm&&T.push(function(){p.resetForm()}),t.clearForm&&T.push(function(){p.clearForm(t.includeHidden)}),!t.dataType&&t.target){var j=t.success||function(){};T.push(function(r,a,n){var i=arguments,o=t.replaceTarget?"replaceWith":"html";e(t.target)[o](r).each(function(){j.apply(this,i)})})}else t.success&&(e.isArray(t.success)?e.merge(T,t.success):T.push(t.success));if(t.success=function(e,r,a){for(var n=t.context||this,i=0,o=T.length;i0,D="multipart/form-data",A=p.attr("enctype")===D||p.attr("encoding")===D,L=i.fileapi&&i.formdata;a("fileAPI :"+L);var F,E=(k||A)&&!L;!1!==t.iframe&&(t.iframe||E)?t.closeKeepAlive?e.get(t.closeKeepAlive,function(){F=c(x)}):F=c(x):F=(k||A)&&L?function(r){for(var a=new FormData,n=0;n0)&&(n={url:n,data:i,dataType:o},"function"==typeof s&&(n.success=s)),n=n||{},n.delegation=n.delegation&&e.isFunction(e.fn.on),!n.delegation&&0===this.length){var u={s:this.selector,c:this.context};return!e.isReady&&u.s?(a("DOM not ready, queuing ajaxForm"),e(function(){e(u.s,u.c).ajaxForm(n)}),this):(a("terminating; zero elements found by selector"+(e.isReady?"":" (DOM not ready)")),this)}return n.delegation?(e(document).off("submit.form-plugin",this.selector,t).off("click.form-plugin",this.selector,r).on("submit.form-plugin",this.selector,n,t).on("click.form-plugin",this.selector,n,r),this):this.ajaxFormUnbind().on("submit.form-plugin",n,t).on("click.form-plugin",n,r)},e.fn.ajaxFormUnbind=function(){return this.off("submit.form-plugin click.form-plugin")},e.fn.formToArray=function(t,r,a){var n=[];if(0===this.length)return n;var o,s=this[0],u=this.attr("id"),c=t||void 0===s.elements?s.getElementsByTagName("*"):s.elements;if(c&&(c=e.makeArray(c)),u&&(t||/(Edge|Trident)\//.test(navigator.userAgent))&&(o=e(':input[form="'+u+'"]').get()).length&&(c=(c||[]).concat(o)),!c||!c.length)return n;e.isFunction(a)&&(c=e.map(c,a));var l,f,d,p,m,h,v;for(l=0,h=c.length;l' + '
     
    ' + '
    ' + '
    ' + '
     
    ' + '
    '; }; Drupal.ProgressBar = function (id, updateCallback, method, errorCallback) { this.id = id; this.method = method || 'GET'; this.updateCallback = updateCallback; this.errorCallback = errorCallback; this.element = $(Drupal.theme('progressBar', id)); }; $.extend(Drupal.ProgressBar.prototype, { setProgress: function setProgress(percentage, message, label) { if (percentage >= 0 && percentage <= 100) { $(this.element).find('div.progress__bar').css('width', percentage + '%'); $(this.element).find('div.progress__percentage').html(percentage + '%'); } $('div.progress__description', this.element).html(message); $('div.progress__label', this.element).html(label); if (this.updateCallback) { this.updateCallback(percentage, message, this); } }, startMonitoring: function startMonitoring(uri, delay) { this.delay = delay; this.uri = uri; this.sendPing(); }, stopMonitoring: function stopMonitoring() { clearTimeout(this.timer); this.uri = null; }, sendPing: function sendPing() { if (this.timer) { clearTimeout(this.timer); } if (this.uri) { var pb = this; var uri = this.uri; if (uri.indexOf('?') === -1) { uri += '?'; } else { uri += '&'; } uri += '_format=json'; $.ajax({ type: this.method, url: uri, data: '', dataType: 'json', success: function success(progress) { if (progress.status === 0) { pb.displayError(progress.data); return; } pb.setProgress(progress.percentage, progress.message, progress.label); pb.timer = setTimeout(function () { pb.sendPing(); }, pb.delay); }, error: function error(xmlhttp) { var e = new Drupal.AjaxError(xmlhttp, pb.uri); pb.displayError('
    ' + e.message + '
    '); } }); } }, displayError: function displayError(string) { var error = $('
    ').html(string); $(this.element).before(error).hide(); if (this.errorCallback) { this.errorCallback(this); } } }); })(jQuery, Drupal);; /** * @file * Extends methods from core/misc/progress.js. */ (function ($, Drupal) { 'use strict'; /** * Theme function for the progress bar. * * @param {string} id * * @return {string} * The HTML for the progress bar. */ Drupal.theme.progressBar = function (id) { return '
    ' + '
    '+ '
    ' + '
    ' + '' + '
    ' + '
    ' + '
    ' + '
    '; }; $.extend(Drupal.ProgressBar.prototype, /** @lends Drupal.ProgressBar */{ /** * Set the percentage and status message for the progressbar. * * @param {number} percentage * @param {string} message * @param {string} label */ setProgress: function (percentage, message, label) { if (percentage >= 0 && percentage <= 100) { $(this.element).find('.progress-bar').css('width', percentage + '%').attr('aria-valuenow', percentage); $(this.element).find('.percentage').html(percentage + '%'); } if (message) { // Remove the unnecessary whitespace at the end of the message. message = message.replace(/ |\s*$/, ''); $('.message', this.element).html(message); } if (label) { $('.progress-label', this.element).html(label); } if (this.updateCallback) { this.updateCallback(percentage, message, this); } }, /** * Display errors on the page. * * @param {string} string */ displayError: function (string) { var error = $('

    ' + Drupal.t('Error message') + '

    ').append(string); $(this.element).before(error).hide(); if (this.errorCallback) { this.errorCallback(this); } } }); })(jQuery, Drupal); ; /** * DO NOT EDIT THIS FILE. * See the following change record for more information, * https://www.drupal.org/node/2815083 * @preserve **/ (function (Drupal) { Drupal.behaviors.responsiveImageAJAX = { attach: function attach() { if (window.picturefill) { window.picturefill(); } } }; })(Drupal);; /** * DO NOT EDIT THIS FILE. * See the following change record for more information, * https://www.drupal.org/node/2815083 * @preserve **/ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } (function ($, window, Drupal, drupalSettings) { Drupal.behaviors.AJAX = { attach: function attach(context, settings) { function loadAjaxBehavior(base) { var elementSettings = settings.ajax[base]; if (typeof elementSettings.selector === 'undefined') { elementSettings.selector = '#' + base; } $(elementSettings.selector).once('drupal-ajax').each(function () { elementSettings.element = this; elementSettings.base = base; Drupal.ajax(elementSettings); }); } Object.keys(settings.ajax || {}).forEach(function (base) { return loadAjaxBehavior(base); }); Drupal.ajax.bindAjaxLinks(document.body); $('.use-ajax-submit').once('ajax').each(function () { var elementSettings = {}; elementSettings.url = $(this.form).attr('action'); elementSettings.setClick = true; elementSettings.event = 'click'; elementSettings.progress = { type: 'throbber' }; elementSettings.base = $(this).attr('id'); elementSettings.element = this; Drupal.ajax(elementSettings); }); }, detach: function detach(context, settings, trigger) { if (trigger === 'unload') { Drupal.ajax.expired().forEach(function (instance) { Drupal.ajax.instances[instance.instanceIndex] = null; }); } } }; Drupal.AjaxError = function (xmlhttp, uri, customMessage) { var statusCode = void 0; var statusText = void 0; var responseText = void 0; if (xmlhttp.status) { statusCode = '\n' + Drupal.t('An AJAX HTTP error occurred.') + '\n' + Drupal.t('HTTP Result Code: !status', { '!status': xmlhttp.status }); } else { statusCode = '\n' + Drupal.t('An AJAX HTTP request terminated abnormally.'); } statusCode += '\n' + Drupal.t('Debugging information follows.'); var pathText = '\n' + Drupal.t('Path: !uri', { '!uri': uri }); statusText = ''; try { statusText = '\n' + Drupal.t('StatusText: !statusText', { '!statusText': $.trim(xmlhttp.statusText) }); } catch (e) {} responseText = ''; try { responseText = '\n' + Drupal.t('ResponseText: !responseText', { '!responseText': $.trim(xmlhttp.responseText) }); } catch (e) {} responseText = responseText.replace(/<("[^"]*"|'[^']*'|[^'">])*>/gi, ''); responseText = responseText.replace(/[\n]+\s+/g, '\n'); var readyStateText = xmlhttp.status === 0 ? '\n' + Drupal.t('ReadyState: !readyState', { '!readyState': xmlhttp.readyState }) : ''; customMessage = customMessage ? '\n' + Drupal.t('CustomMessage: !customMessage', { '!customMessage': customMessage }) : ''; this.message = statusCode + pathText + statusText + customMessage + responseText + readyStateText; this.name = 'AjaxError'; }; Drupal.AjaxError.prototype = new Error(); Drupal.AjaxError.prototype.constructor = Drupal.AjaxError; Drupal.ajax = function (settings) { if (arguments.length !== 1) { throw new Error('Drupal.ajax() function must be called with one configuration object only'); } var base = settings.base || false; var element = settings.element || false; delete settings.base; delete settings.element; if (!settings.progress && !element) { settings.progress = false; } var ajax = new Drupal.Ajax(base, element, settings); ajax.instanceIndex = Drupal.ajax.instances.length; Drupal.ajax.instances.push(ajax); return ajax; }; Drupal.ajax.instances = []; Drupal.ajax.expired = function () { return Drupal.ajax.instances.filter(function (instance) { return instance && instance.element !== false && !document.body.contains(instance.element); }); }; Drupal.ajax.bindAjaxLinks = function (element) { $(element).find('.use-ajax').once('ajax').each(function (i, ajaxLink) { var $linkElement = $(ajaxLink); var elementSettings = { progress: { type: 'throbber' }, dialogType: $linkElement.data('dialog-type'), dialog: $linkElement.data('dialog-options'), dialogRenderer: $linkElement.data('dialog-renderer'), base: $linkElement.attr('id'), element: ajaxLink }; var href = $linkElement.attr('href'); if (href) { elementSettings.url = href; elementSettings.event = 'click'; } Drupal.ajax(elementSettings); }); }; Drupal.Ajax = function (base, element, elementSettings) { var defaults = { event: element ? 'mousedown' : null, keypress: true, selector: base ? '#' + base : null, effect: 'none', speed: 'none', method: 'replaceWith', progress: { type: 'throbber', message: Drupal.t('Please wait...') }, submit: { js: true } }; $.extend(this, defaults, elementSettings); this.commands = new Drupal.AjaxCommands(); this.instanceIndex = false; if (this.wrapper) { this.wrapper = '#' + this.wrapper; } this.element = element; this.element_settings = elementSettings; this.elementSettings = elementSettings; if (this.element && this.element.form) { this.$form = $(this.element.form); } if (!this.url) { var $element = $(this.element); if ($element.is('a')) { this.url = $element.attr('href'); } else if (this.element && element.form) { this.url = this.$form.attr('action'); } } var originalUrl = this.url; this.url = this.url.replace(/\/nojs(\/|$|\?|#)/, '/ajax$1'); if (drupalSettings.ajaxTrustedUrl[originalUrl]) { drupalSettings.ajaxTrustedUrl[this.url] = true; } var ajax = this; ajax.options = { url: ajax.url, data: ajax.submit, beforeSerialize: function beforeSerialize(elementSettings, options) { return ajax.beforeSerialize(elementSettings, options); }, beforeSubmit: function beforeSubmit(formValues, elementSettings, options) { ajax.ajaxing = true; return ajax.beforeSubmit(formValues, elementSettings, options); }, beforeSend: function beforeSend(xmlhttprequest, options) { ajax.ajaxing = true; return ajax.beforeSend(xmlhttprequest, options); }, success: function success(response, status, xmlhttprequest) { if (typeof response === 'string') { response = $.parseJSON(response); } if (response !== null && !drupalSettings.ajaxTrustedUrl[ajax.url]) { if (xmlhttprequest.getResponseHeader('X-Drupal-Ajax-Token') !== '1') { var customMessage = Drupal.t('The response failed verification so will not be processed.'); return ajax.error(xmlhttprequest, ajax.url, customMessage); } } return ajax.success(response, status); }, complete: function complete(xmlhttprequest, status) { ajax.ajaxing = false; if (status === 'error' || status === 'parsererror') { return ajax.error(xmlhttprequest, ajax.url); } }, dataType: 'json', jsonp: false, type: 'POST' }; if (elementSettings.dialog) { ajax.options.data.dialogOptions = elementSettings.dialog; } if (ajax.options.url.indexOf('?') === -1) { ajax.options.url += '?'; } else { ajax.options.url += '&'; } var wrapper = 'drupal_' + (elementSettings.dialogType || 'ajax'); if (elementSettings.dialogRenderer) { wrapper += '.' + elementSettings.dialogRenderer; } ajax.options.url += Drupal.ajax.WRAPPER_FORMAT + '=' + wrapper; $(ajax.element).on(elementSettings.event, function (event) { if (!drupalSettings.ajaxTrustedUrl[ajax.url] && !Drupal.url.isLocal(ajax.url)) { throw new Error(Drupal.t('The callback URL is not local and not trusted: !url', { '!url': ajax.url })); } return ajax.eventResponse(this, event); }); if (elementSettings.keypress) { $(ajax.element).on('keypress', function (event) { return ajax.keypressResponse(this, event); }); } if (elementSettings.prevent) { $(ajax.element).on(elementSettings.prevent, false); } }; Drupal.ajax.WRAPPER_FORMAT = '_wrapper_format'; Drupal.Ajax.AJAX_REQUEST_PARAMETER = '_drupal_ajax'; Drupal.Ajax.prototype.execute = function () { if (this.ajaxing) { return; } try { this.beforeSerialize(this.element, this.options); return $.ajax(this.options); } catch (e) { this.ajaxing = false; window.alert('An error occurred while attempting to process ' + this.options.url + ': ' + e.message); return $.Deferred().reject(); } }; Drupal.Ajax.prototype.keypressResponse = function (element, event) { var ajax = this; if (event.which === 13 || event.which === 32 && element.type !== 'text' && element.type !== 'textarea' && element.type !== 'tel' && element.type !== 'number') { event.preventDefault(); event.stopPropagation(); $(element).trigger(ajax.elementSettings.event); } }; Drupal.Ajax.prototype.eventResponse = function (element, event) { event.preventDefault(); event.stopPropagation(); var ajax = this; if (ajax.ajaxing) { return; } try { if (ajax.$form) { if (ajax.setClick) { element.form.clk = element; } ajax.$form.ajaxSubmit(ajax.options); } else { ajax.beforeSerialize(ajax.element, ajax.options); $.ajax(ajax.options); } } catch (e) { ajax.ajaxing = false; window.alert('An error occurred while attempting to process ' + ajax.options.url + ': ' + e.message); } }; Drupal.Ajax.prototype.beforeSerialize = function (element, options) { if (this.$form && document.body.contains(this.$form.get(0))) { var settings = this.settings || drupalSettings; Drupal.detachBehaviors(this.$form.get(0), settings, 'serialize'); } options.data[Drupal.Ajax.AJAX_REQUEST_PARAMETER] = 1; var pageState = drupalSettings.ajaxPageState; options.data['ajax_page_state[theme]'] = pageState.theme; options.data['ajax_page_state[theme_token]'] = pageState.theme_token; options.data['ajax_page_state[libraries]'] = pageState.libraries; }; Drupal.Ajax.prototype.beforeSubmit = function (formValues, element, options) {}; Drupal.Ajax.prototype.beforeSend = function (xmlhttprequest, options) { if (this.$form) { options.extraData = options.extraData || {}; options.extraData.ajax_iframe_upload = '1'; var v = $.fieldValue(this.element); if (v !== null) { options.extraData[this.element.name] = v; } } $(this.element).prop('disabled', true); if (!this.progress || !this.progress.type) { return; } var progressIndicatorMethod = 'setProgressIndicator' + this.progress.type.slice(0, 1).toUpperCase() + this.progress.type.slice(1).toLowerCase(); if (progressIndicatorMethod in this && typeof this[progressIndicatorMethod] === 'function') { this[progressIndicatorMethod].call(this); } }; Drupal.theme.ajaxProgressThrobber = function (message) { var messageMarkup = typeof message === 'string' ? Drupal.theme('ajaxProgressMessage', message) : ''; var throbber = '
     
    '; return '
    ' + throbber + messageMarkup + '
    '; }; Drupal.theme.ajaxProgressIndicatorFullscreen = function () { return '
     
    '; }; Drupal.theme.ajaxProgressMessage = function (message) { return '
    ' + message + '
    '; }; Drupal.theme.ajaxProgressBar = function ($element) { return $('
    ').append($element); }; Drupal.Ajax.prototype.setProgressIndicatorBar = function () { var progressBar = new Drupal.ProgressBar('ajax-progress-' + this.element.id, $.noop, this.progress.method, $.noop); if (this.progress.message) { progressBar.setProgress(-1, this.progress.message); } if (this.progress.url) { progressBar.startMonitoring(this.progress.url, this.progress.interval || 1500); } this.progress.element = $(Drupal.theme('ajaxProgressBar', progressBar.element)); this.progress.object = progressBar; $(this.element).after(this.progress.element); }; Drupal.Ajax.prototype.setProgressIndicatorThrobber = function () { this.progress.element = $(Drupal.theme('ajaxProgressThrobber', this.progress.message)); $(this.element).after(this.progress.element); }; Drupal.Ajax.prototype.setProgressIndicatorFullscreen = function () { this.progress.element = $(Drupal.theme('ajaxProgressIndicatorFullscreen')); $('body').append(this.progress.element); }; Drupal.Ajax.prototype.success = function (response, status) { var _this = this; if (this.progress.element) { $(this.progress.element).remove(); } if (this.progress.object) { this.progress.object.stopMonitoring(); } $(this.element).prop('disabled', false); var elementParents = $(this.element).parents('[data-drupal-selector]').addBack().toArray(); var focusChanged = false; Object.keys(response || {}).forEach(function (i) { if (response[i].command && _this.commands[response[i].command]) { _this.commands[response[i].command](_this, response[i], status); if (response[i].command === 'invoke' && response[i].method === 'focus') { focusChanged = true; } } }); if (!focusChanged && this.element && !$(this.element).data('disable-refocus')) { var target = false; for (var n = elementParents.length - 1; !target && n >= 0; n--) { target = document.querySelector('[data-drupal-selector="' + elementParents[n].getAttribute('data-drupal-selector') + '"]'); } if (target) { $(target).trigger('focus'); } } if (this.$form && document.body.contains(this.$form.get(0))) { var settings = this.settings || drupalSettings; Drupal.attachBehaviors(this.$form.get(0), settings); } this.settings = null; }; Drupal.Ajax.prototype.getEffect = function (response) { var type = response.effect || this.effect; var speed = response.speed || this.speed; var effect = {}; if (type === 'none') { effect.showEffect = 'show'; effect.hideEffect = 'hide'; effect.showSpeed = ''; } else if (type === 'fade') { effect.showEffect = 'fadeIn'; effect.hideEffect = 'fadeOut'; effect.showSpeed = speed; } else { effect.showEffect = type + 'Toggle'; effect.hideEffect = type + 'Toggle'; effect.showSpeed = speed; } return effect; }; Drupal.Ajax.prototype.error = function (xmlhttprequest, uri, customMessage) { if (this.progress.element) { $(this.progress.element).remove(); } if (this.progress.object) { this.progress.object.stopMonitoring(); } $(this.wrapper).show(); $(this.element).prop('disabled', false); if (this.$form && document.body.contains(this.$form.get(0))) { var settings = this.settings || drupalSettings; Drupal.attachBehaviors(this.$form.get(0), settings); } throw new Drupal.AjaxError(xmlhttprequest, uri, customMessage); }; Drupal.theme.ajaxWrapperNewContent = function ($newContent, ajax, response) { return (response.effect || ajax.effect) !== 'none' && $newContent.filter(function (i) { return !($newContent[i].nodeName === '#comment' || $newContent[i].nodeName === '#text' && /^(\s|\n|\r)*$/.test($newContent[i].textContent)); }).length > 1 ? Drupal.theme('ajaxWrapperMultipleRootElements', $newContent) : $newContent; }; Drupal.theme.ajaxWrapperMultipleRootElements = function ($elements) { return $('
    ').append($elements); }; Drupal.AjaxCommands = function () {}; Drupal.AjaxCommands.prototype = { insert: function insert(ajax, response) { var $wrapper = response.selector ? $(response.selector) : $(ajax.wrapper); var method = response.method || ajax.method; var effect = ajax.getEffect(response); var settings = response.settings || ajax.settings || drupalSettings; var $newContent = $($.parseHTML(response.data, document, true)); $newContent = Drupal.theme('ajaxWrapperNewContent', $newContent, ajax, response); switch (method) { case 'html': case 'replaceWith': case 'replaceAll': case 'empty': case 'remove': Drupal.detachBehaviors($wrapper.get(0), settings); break; default: break; } $wrapper[method]($newContent); if (effect.showEffect !== 'show') { $newContent.hide(); } var $ajaxNewContent = $newContent.find('.ajax-new-content'); if ($ajaxNewContent.length) { $ajaxNewContent.hide(); $newContent.show(); $ajaxNewContent[effect.showEffect](effect.showSpeed); } else if (effect.showEffect !== 'show') { $newContent[effect.showEffect](effect.showSpeed); } if ($newContent.parents('html').length) { $newContent.each(function (index, element) { if (element.nodeType === Node.ELEMENT_NODE) { Drupal.attachBehaviors(element, settings); } }); } }, remove: function remove(ajax, response, status) { var settings = response.settings || ajax.settings || drupalSettings; $(response.selector).each(function () { Drupal.detachBehaviors(this, settings); }).remove(); }, changed: function changed(ajax, response, status) { var $element = $(response.selector); if (!$element.hasClass('ajax-changed')) { $element.addClass('ajax-changed'); if (response.asterisk) { $element.find(response.asterisk).append(' * '); } } }, alert: function alert(ajax, response, status) { window.alert(response.text, response.title); }, announce: function announce(ajax, response) { if (response.priority) { Drupal.announce(response.text, response.priority); } else { Drupal.announce(response.text); } }, redirect: function redirect(ajax, response, status) { window.location = response.url; }, css: function css(ajax, response, status) { $(response.selector).css(response.argument); }, settings: function settings(ajax, response, status) { var ajaxSettings = drupalSettings.ajax; if (ajaxSettings) { Drupal.ajax.expired().forEach(function (instance) { if (instance.selector) { var selector = instance.selector.replace('#', ''); if (selector in ajaxSettings) { delete ajaxSettings[selector]; } } }); } if (response.merge) { $.extend(true, drupalSettings, response.settings); } else { ajax.settings = response.settings; } }, data: function data(ajax, response, status) { $(response.selector).data(response.name, response.value); }, invoke: function invoke(ajax, response, status) { var $element = $(response.selector); $element[response.method].apply($element, _toConsumableArray(response.args)); }, restripe: function restripe(ajax, response, status) { $(response.selector).find('> tbody > tr:visible, > tr:visible').removeClass('odd even').filter(':even').addClass('odd').end().filter(':odd').addClass('even'); }, update_build_id: function update_build_id(ajax, response, status) { $('input[name="form_build_id"][value="' + response.old + '"]').val(response.new); }, add_css: function add_css(ajax, response, status) { $('head').prepend(response.data); }, message: function message(ajax, response) { var messages = new Drupal.Message(document.querySelector(response.messageWrapperQuerySelector)); if (response.clearPrevious) { messages.clear(); } messages.add(response.message, response.messageOptions); } }; })(jQuery, window, Drupal, drupalSettings);; /** * @file * Extends methods from core/misc/ajax.js. */ (function ($, window, Drupal, drupalSettings) { /** * Attempts to find the closest glyphicon progress indicator. * * @param {jQuery|Element} element * A DOM element. * * @returns {jQuery} * A jQuery object. */ Drupal.Ajax.prototype.findGlyphicon = function (element) { return $(element).closest('.form-item').find('.ajax-progress.glyphicon') }; /** * Starts the spinning of the glyphicon progress indicator. * * @param {jQuery|Element} element * A DOM element. * @param {string} [message] * An optional message to display (tooltip) for the progress. * * @returns {jQuery} * A jQuery object. */ Drupal.Ajax.prototype.glyphiconStart = function (element, message) { var $glyphicon = this.findGlyphicon(element); if ($glyphicon[0]) { $glyphicon.addClass('glyphicon-spin'); // Add any message as a tooltip to the glyphicon. if (drupalSettings.bootstrap.tooltip_enabled) { $glyphicon .removeAttr('data-toggle') .removeAttr('data-original-title') .removeAttr('title') .tooltip('destroy') ; if (message) { $glyphicon.attr('data-toggle', 'tooltip').attr('title', message).tooltip(); } } // Append a message for screen readers. if (message) { $glyphicon.parent().append('
    ' + message + '
    '); } } return $glyphicon; }; /** * Stop the spinning of a glyphicon progress indicator. * * @param {jQuery|Element} element * A DOM element. */ Drupal.Ajax.prototype.glyphiconStop = function (element) { var $glyphicon = this.findGlyphicon(element); if ($glyphicon[0]) { $glyphicon.removeClass('glyphicon-spin'); if (drupalSettings.bootstrap.tooltip_enabled) { $glyphicon .removeAttr('data-toggle') .removeAttr('data-original-title') .removeAttr('title') .tooltip('destroy') ; } } }; /** * Sets the throbber progress indicator. */ Drupal.Ajax.prototype.setProgressIndicatorThrobber = function () { var $element = $(this.element); // Find an existing glyphicon progress indicator. var $glyphicon = this.glyphiconStart($element, this.progress.message); if ($glyphicon[0]) { this.progress.element = $glyphicon.parent(); this.progress.glyphicon = true; return; } // Otherwise, add a glyphicon throbber after the element. if (!this.progress.element) { this.progress.element = $(Drupal.theme('ajaxThrobber')); } if (this.progress.message) { this.progress.element.after('
    ' + this.progress.message + '
    '); } // If element is an input DOM element type (not :input), append after. if ($element.is('input')) { $element.after(this.progress.element); } // Otherwise append the throbber inside the element. else { $element.append(this.progress.element); } }; /** * Handler for the form redirection completion. * * @param {Array.} response * @param {number} status */ Drupal.Ajax.prototype.success = function (response, status) { if (this.progress.element) { // Stop a glyphicon throbber. if (this.progress.glyphicon) { this.glyphiconStop(this.progress.element); } // Remove the progress element. else { this.progress.element.remove(); } // Remove any message set. this.progress.element.parent().find('.message').remove(); } // -------------------------------------------------------- // Everything below is from core/misc/ajax.js. // -------------------------------------------------------- if (this.progress.object) { this.progress.object.stopMonitoring(); } $(this.element).prop('disabled', false); // Save element's ancestors tree so if the element is removed from the dom // we can try to refocus one of its parents. Using addBack reverse the // result array, meaning that index 0 is the highest parent in the hierarchy // in this situation it is usually a
    element. var elementParents = $(this.element).parents('[data-drupal-selector]').addBack().toArray(); // Track if any command is altering the focus so we can avoid changing the // focus set by the Ajax command. var focusChanged = false; for (var i in response) { if (response.hasOwnProperty(i) && response[i].command && this.commands[response[i].command]) { this.commands[response[i].command](this, response[i], status); if (response[i].command === 'invoke' && response[i].method === 'focus') { focusChanged = true; } } } // If the focus hasn't be changed by the ajax commands, try to refocus the // triggering element or one of its parents if that element does not exist // anymore. if (!focusChanged && this.element && !$(this.element).data('disable-refocus')) { var target = false; for (var n = elementParents.length - 1; !target && n > 0; n--) { target = document.querySelector('[data-drupal-selector="' + elementParents[n].getAttribute('data-drupal-selector') + '"]'); } if (target) { $(target).trigger('focus'); } } // Reattach behaviors, if they were detached in beforeSerialize(). The // attachBehaviors() called on the new content from processing the response // commands is not sufficient, because behaviors from the entire form need // to be reattached. if (this.$form) { var settings = this.settings || drupalSettings; Drupal.attachBehaviors(this.$form.get(0), settings); } // Remove any response-specific settings so they don't get used on the next // call by mistake. this.settings = null; }; })(jQuery, this, Drupal, drupalSettings); ; /** * DO NOT EDIT THIS FILE. * See the following change record for more information, * https://www.drupal.org/node/2815083 * @preserve **/ (function ($, Drupal, drupalSettings) { Drupal.Views = {}; Drupal.Views.parseQueryString = function (query) { var args = {}; var pos = query.indexOf('?'); if (pos !== -1) { query = query.substring(pos + 1); } var pair = void 0; var pairs = query.split('&'); for (var i = 0; i < pairs.length; i++) { pair = pairs[i].split('='); if (pair[0] !== 'q' && pair[1]) { args[decodeURIComponent(pair[0].replace(/\+/g, ' '))] = decodeURIComponent(pair[1].replace(/\+/g, ' ')); } } return args; }; Drupal.Views.parseViewArgs = function (href, viewPath) { var returnObj = {}; var path = Drupal.Views.getPath(href); var viewHref = Drupal.url(viewPath).substring(drupalSettings.path.baseUrl.length); if (viewHref && path.substring(0, viewHref.length + 1) === viewHref + '/') { returnObj.view_args = decodeURIComponent(path.substring(viewHref.length + 1, path.length)); returnObj.view_path = path; } return returnObj; }; Drupal.Views.pathPortion = function (href) { var protocol = window.location.protocol; if (href.substring(0, protocol.length) === protocol) { href = href.substring(href.indexOf('/', protocol.length + 2)); } return href; }; Drupal.Views.getPath = function (href) { href = Drupal.Views.pathPortion(href); href = href.substring(drupalSettings.path.baseUrl.length, href.length); if (href.substring(0, 3) === '?q=') { href = href.substring(3, href.length); } var chars = ['#', '?', '&']; for (var i = 0; i < chars.length; i++) { if (href.indexOf(chars[i]) > -1) { href = href.substr(0, href.indexOf(chars[i])); } } return href; }; })(jQuery, Drupal, drupalSettings);; /** * DO NOT EDIT THIS FILE. * See the following change record for more information, * https://www.drupal.org/node/2815083 * @preserve **/ (function ($, Drupal, drupalSettings) { Drupal.behaviors.ViewsAjaxView = {}; Drupal.behaviors.ViewsAjaxView.attach = function (context, settings) { if (settings && settings.views && settings.views.ajaxViews) { var ajaxViews = settings.views.ajaxViews; Object.keys(ajaxViews || {}).forEach(function (i) { Drupal.views.instances[i] = new Drupal.views.ajaxView(ajaxViews[i]); }); } }; Drupal.behaviors.ViewsAjaxView.detach = function (context, settings, trigger) { if (trigger === 'unload') { if (settings && settings.views && settings.views.ajaxViews) { var ajaxViews = settings.views.ajaxViews; Object.keys(ajaxViews || {}).forEach(function (i) { var selector = '.js-view-dom-id-' + ajaxViews[i].view_dom_id; if ($(selector, context).length) { delete Drupal.views.instances[i]; delete settings.views.ajaxViews[i]; } }); } } }; Drupal.views = {}; Drupal.views.instances = {}; Drupal.views.ajaxView = function (settings) { var selector = '.js-view-dom-id-' + settings.view_dom_id; this.$view = $(selector); var ajaxPath = drupalSettings.views.ajax_path; if (ajaxPath.constructor.toString().indexOf('Array') !== -1) { ajaxPath = ajaxPath[0]; } var queryString = window.location.search || ''; if (queryString !== '') { queryString = queryString.slice(1).replace(/q=[^&]+&?|&?render=[^&]+/, ''); if (queryString !== '') { queryString = (/\?/.test(ajaxPath) ? '&' : '?') + queryString; } } this.element_settings = { url: ajaxPath + queryString, submit: settings, setClick: true, event: 'click', selector: selector, progress: { type: 'fullscreen' } }; this.settings = settings; this.$exposed_form = $('form#views-exposed-form-' + settings.view_name.replace(/_/g, '-') + '-' + settings.view_display_id.replace(/_/g, '-')); this.$exposed_form.once('exposed-form').each($.proxy(this.attachExposedFormAjax, this)); this.$view.filter($.proxy(this.filterNestedViews, this)).once('ajax-pager').each($.proxy(this.attachPagerAjax, this)); var selfSettings = $.extend({}, this.element_settings, { event: 'RefreshView', base: this.selector, element: this.$view.get(0) }); this.refreshViewAjax = Drupal.ajax(selfSettings); }; Drupal.views.ajaxView.prototype.attachExposedFormAjax = function () { var that = this; this.exposedFormAjax = []; $('input[type=submit], input[type=image]', this.$exposed_form).not('[data-drupal-selector=edit-reset]').each(function (index) { var selfSettings = $.extend({}, that.element_settings, { base: $(this).attr('id'), element: this }); that.exposedFormAjax[index] = Drupal.ajax(selfSettings); }); }; Drupal.views.ajaxView.prototype.filterNestedViews = function () { return !this.$view.parents('.view').length; }; Drupal.views.ajaxView.prototype.attachPagerAjax = function () { this.$view.find('ul.js-pager__items > li > a, th.views-field a, .attachment .views-summary a').each($.proxy(this.attachPagerLinkAjax, this)); }; Drupal.views.ajaxView.prototype.attachPagerLinkAjax = function (id, link) { var $link = $(link); var viewData = {}; var href = $link.attr('href'); $.extend(viewData, this.settings, Drupal.Views.parseQueryString(href), Drupal.Views.parseViewArgs(href, this.settings.view_base_path)); var selfSettings = $.extend({}, this.element_settings, { submit: viewData, base: false, element: link }); this.pagerAjax = Drupal.ajax(selfSettings); }; Drupal.AjaxCommands.prototype.viewsScrollTop = function (ajax, response) { var offset = $(response.selector).offset(); var scrollTarget = response.selector; while ($(scrollTarget).scrollTop() === 0 && $(scrollTarget).parent()) { scrollTarget = $(scrollTarget).parent(); } if (offset.top - 10 < $(scrollTarget).scrollTop()) { $(scrollTarget).animate({ scrollTop: offset.top - 10 }, 500); } }; })(jQuery, Drupal, drupalSettings);; /** * @file * Extends core ajax_view.js. */ (function ($, Drupal) { 'use strict'; /** * @method */ Drupal.views.ajaxView.prototype.attachExposedFormAjax = function () { var that = this; this.exposedFormAjax = []; $('button[type=submit], input[type=submit], input[type=image]', this.$exposed_form).not('[data-drupal-selector=edit-reset]').each(function (index) { var self_settings = $.extend({}, that.element_settings, { base: $(this).attr('id'), element: this }); that.exposedFormAjax[index] = Drupal.ajax(self_settings); }); }; })(jQuery, Drupal); ; /** * @file * Javascript for the geolocation module. */ /** * @typedef {Object} GeolocationSettings * * @property {GeolocationMapSettings[]} maps * @property {Object} mapCenter */ /** * @type {GeolocationSettings} drupalSettings.geolocation */ /** * @typedef {Object} GeolocationMapSettings * * @property {String} [type] Map type * @property {String} id * @property {Object} settings * @property {Number} lat * @property {Number} lng * @property {Object[]} map_center * @property {jQuery} wrapper * @property {GeolocationMapMarker[]} mapMarkers * @property {GeolocationShape[]} mapShapes */ /** * Callback when map is clicked. * * @callback GeolocationMapClickCallback * * @param {GeolocationCoordinates} location - Click location. */ /** * Callback when a marker is added or removed. * * @callback GeolocationMarkerCallback * * @param {GeolocationMapMarker} marker - Map marker. */ /** * Callback when map is right-clicked. * * @callback GeolocationMapContextClickCallback * * @param {GeolocationCoordinates} location - Click location. */ /** * Callback when map provider becomes available. * * @callback GeolocationMapInitializedCallback * * @param {GeolocationMapInterface} map - Geolocation map. */ /** * Callback when map bounds changed. * * @callback GeolocationBoundsChangedCallback * * @param object bounds - New bounds. */ /** * Callback when map fully loaded. * * @callback GeolocationMapPopulatedCallback * * @param {GeolocationMapInterface} map - Geolocation map. */ /** * Callback when and only when map is updated. * * @callback GeolocationMapUpdatedCallback * * @param {GeolocationMapInterface, GeolocationMapSettings} map - Geolocation map. */ /** * @typedef {Object} GeolocationCoordinates * * @property {Number} lat * @property {Number} lng */ /** * @typedef {Object} GeolocationCenterOption * * @property {Object} map_center_id * @property {Object} option_id * @property {Object} settings */ /** * @typedef {Object} GeolocationMapMarker * * @property {GeolocationCoordinates} position * @property {string} title * @property {boolean} [setMarker] * @property {string} [icon] * @property {string} [label] * @property {jQuery} locationWrapper */ /** * @typedef {Object} GeolocationShape * * @property {GeolocationCoordinates[]} coordinates * @property {jQuery} shapeWrapper * @property {string} shape * @property {string} [title] * @property {string} [strokeColor] * @property {int} [strokeWidth] * @property {number} [strokeOpacity] * @property {string} [fillColor] * @property {number} [fillOpacity] */ /** * Interface for classes that represent a color. * * @interface GeolocationMapInterface * * @property {Boolean} initialized - True when map provider available and initializedCallbacks executed. * @property {Boolean} loaded - True when map fully loaded and all loadCallbacks executed. * @property {String} id * @property {GeolocationMapSettings} settings * @property {Number} lat * @property {Number} lng * @property {Object[]} mapCenter * @property {jQuery} wrapper * @property {jQuery} container * @property {Object[]} mapMarkers * * @property {function({jQuery}):{jQuery}} addControl - Add control to map, identified by classes. * @property {function()} removeControls - Remove controls from map. * * @property {function()} populatedCallback - Executes {GeolocationMapPopulatedCallback[]} for this map. * @property {function({GeolocationMapPopulatedCallback})} addPopulatedCallback - Adds a callback that will be called when map is fully loaded. * @property {function()} initializedCallback - Executes {GeolocationMapInitializedCallbacks[]} for this map. * @property {function({GeolocationMapInitializedCallback})} addInitializedCallback - Adds a callback that will be called when map provider becomes available. * @property {function({GeolocationMapSettings})} updatedCallback - Executes {GeolocationMapUpdatedCallbacks[]} for this map. * @property {function({GeolocationMapUpdatedCallbacks})} addUpdatedCallback - Adds a callback that will be called when and only when an already existing map is updated. * * @property {function({GeolocationMapMarker}):{GeolocationMapMarker}} setMapMarker - Set marker on map. * @property {function({GeolocationMapMarker})} removeMapMarker - Remove single marker. * @property {function()} removeMapMarkers - Remove all markers from map. * * @property {function({GeolocationShape})} addShape - Add shape to map. * @property {function({GeolocationShape})} removeShape - Remove shape from map. * @property {function()} removeShapes - Remove all shapes from map. * * @property {function():{Promise}} getZoom - Get zoom. * @property {function({string}?, {Boolean}?)} setZoom - Set zoom. * @property {function():{GeolocationCoordinates}} getCenter - Get map center coordinates. * @property {function({string})} setCenter - Center map by plugin. * @property {function({GeolocationCoordinates}, {Number}?, {string}?)} setCenterByCoordinates - Center map on coordinates. * @property {function({GeolocationMapMarker[]}?, {String}?)} fitMapToMarkers - Fit map to markers. * @property {function({GeolocationMapMarker[]}?):{Object}} getMarkerBoundaries - Get marker boundaries. * @property {function({Object}, {String}?)} fitBoundaries - Fit map to bounds. * * @property {function({Event})} clickCallback - Executes {GeolocationMapClickCallbacks} for this map. * @property {function({GeolocationMapClickCallback})} addClickCallback - Adds a callback that will be called when map is clicked. * * @property {function({Event})} doubleClickCallback - Executes {GeolocationMapClickCallbacks} for this map. * @property {function({GeolocationMapClickCallback})} addDoubleClickCallback - Adds a callback that will be called on double click. * * @property {function({Event})} contextClickCallback - Executes {GeolocationMapContextClickCallbacks} for this map. * @property {function({GeolocationMapContextClickCallback})} addContextClickCallback - Adds a callback that will be called when map is clicked. * * @property {function({GeolocationMapMarker})} markerAddedCallback - Executes {GeolocationMarkerCallback} for this map. * @property {function({GeolocationMarkerCallback})} addMarkerAddedCallback - Adds a callback that will be called on marker(s) being added. * * @property {function({GeolocationMapMarker})} markerRemoveCallback - Executes {GeolocationMarkerCallback} for this map. * @property {function({GeolocationMarkerCallback})} addMarkerRemoveCallback - Adds a callback that will be called before marker is removed. * * @property {function()} boundsChangedCallback - Executes {GeolocationBoundsChangedCallback} for this map. * @property {function({GeolocationBoundsChangedCallback})} addBoundsChangedCallback - Adds a callback that will be called when map bounds changed. */ /** * Geolocation map API. * * @implements {GeolocationMapInterface} */ (function ($, Drupal) { 'use strict'; /** * @namespace * @prop {Object} Drupal.geolocation */ Drupal.geolocation = Drupal.geolocation || {}; /** * @type {GeolocationMapInterface[]} * @prop {GeolocationMapSettings} settings The map settings. */ Drupal.geolocation.maps = Drupal.geolocation.maps || []; Drupal.geolocation.mapCenter = Drupal.geolocation.mapCenter || {}; /** * Geolocation map. * * @constructor * @abstract * @implements {GeolocationMapInterface} * * @param {GeolocationMapSettings} mapSettings Setting to create map. */ function GeolocationMapBase(mapSettings) { this.settings = mapSettings.settings || {}; this.wrapper = mapSettings.wrapper; this.container = mapSettings.wrapper.find('.geolocation-map-container').first(); if (this.container.length !== 1) { throw "Geolocation - Map container not found"; } this.initialized = false; this.populated = false; this.lat = mapSettings.lat; this.lng = mapSettings.lng; if (typeof mapSettings.id === 'undefined') { this.id = 'map' + Math.floor(Math.random() * 10000); } else { this.id = mapSettings.id; } this.mapCenter = mapSettings.map_center; this.mapMarkers = this.mapMarkers || []; this.mapShapes = this.mapShapes || []; return this; } GeolocationMapBase.prototype = { addControl: function (element) { // Stub. }, removeControls: function () { // Stub. }, getZoom: function () { // Stub. }, setZoom: function (zoom, defer) { // Stub. }, getCenter: function () { // Stub. }, setCenter: function () { if (typeof this.wrapper.data('preserve-map-center') !== 'undefined') { return; } this.setZoom(); this.setCenterByCoordinates({lat: this.lat, lng: this.lng}); if (typeof this.mapCenter !== 'undefined') { var that = this; var centerOptions = Object // .values(this.mapCenter) // Reenable once IE11 is dead. Hopefully soon. .keys(that.mapCenter).map(function (item) { return that.mapCenter[item]; }) // IE11 fix from #3046802. .sort(function (a, b) { return a.weight - b.weight; }); centerOptions.some( /** * @param {GeolocationCenterOption} centerOption */ function (centerOption) { if (typeof Drupal.geolocation.mapCenter[centerOption.map_center_id] === 'function') { return Drupal.geolocation.mapCenter[centerOption.map_center_id](that, centerOption); } } ); } }, setCenterByCoordinates: function (coordinates, accuracy, identifier) { this.centerUpdatedCallback(coordinates, accuracy, identifier); }, setMapMarker: function (marker) { this.mapMarkers.push(marker); this.markerAddedCallback(marker); }, removeMapMarker: function (marker) { var that = this; $.each( this.mapMarkers, /** * @param {integer} index - Current index. * @param {GeolocationMapMarker} item - Current marker. */ function (index, item) { if (item === marker) { that.markerRemoveCallback(marker); that.mapMarkers.splice(Number(index), 1); } } ); }, removeMapMarkers: function () { var that = this; var shallowCopy = $.extend({}, this.mapMarkers); $.each( shallowCopy, /** * @param {integer} index - Current index. * @param {GeolocationMapMarker} item - Current marker. */ function (index, item) { if (typeof item === 'undefined') { return; } that.removeMapMarker(item); } ); }, addShape: function (shape) { this.mapShapes.push(shape); }, removeShape: function (shape) { var that = this; $.each( this.mapShapes, /** * @param {integer} index - Current index. * @param {GeolocationShape} item - Current shape. */ function (index, item) { if (item === shape) { that.mapShapes.splice(Number(index), 1); } } ); }, removeShapes: function () { var that = this; var shallowCopy = $.extend({}, this.mapShapes); $.each( shallowCopy, /** * @param {integer} index - Current index. * @param {GeolocationShape} item - Current shape. */ function (index, item) { if (typeof item === 'undefined') { return; } that.removeShape(item); } ); }, fitMapToMarkers: function (markers, identifier) { var boundaries = this.getMarkerBoundaries(); if (boundaries === false) { return false; } this.fitBoundaries(boundaries, identifier); }, getMarkerBoundaries: function (markers) { // Stub. }, fitBoundaries: function (boundaries, identifier) { this.centerUpdatedCallback(this.getCenter(), null, identifier); }, clickCallback: function (location) { this.clickCallbacks = this.clickCallbacks || []; $.each(this.clickCallbacks, function (index, callback) { callback(location); }); }, addClickCallback: function (callback) { this.clickCallbacks = this.clickCallbacks || []; this.clickCallbacks.push(callback); }, doubleClickCallback: function (location) { this.doubleClickCallbacks = this.doubleClickCallbacks || []; $.each(this.doubleClickCallbacks, function (index, callback) { callback(location); }); }, addDoubleClickCallback: function (callback) { this.doubleClickCallbacks = this.doubleClickCallbacks || []; this.doubleClickCallbacks.push(callback); }, contextClickCallback: function (location) { this.contextClickCallbacks = this.contextClickCallbacks || []; $.each(this.contextClickCallbacks, function (index, callback) { callback(location); }); }, addContextClickCallback: function (callback) { this.contextClickCallbacks = this.contextClickCallbacks || []; this.contextClickCallbacks.push(callback); }, initializedCallback: function () { this.initializedCallbacks = this.initializedCallbacks || []; while (this.initializedCallbacks.length > 0) { this.initializedCallbacks.shift()(this); } this.initialized = true; }, addInitializedCallback: function (callback) { if (this.initialized) { callback(this); } else { this.initializedCallbacks = this.initializedCallbacks || []; this.initializedCallbacks.push(callback); } }, updatedCallback: function (mapSettings) { var that = this; this.updatedCallbacks = this.updatedCallbacks || []; this.updatedCallbacks.forEach(function (callback) { callback(that, mapSettings); }); }, addUpdatedCallback: function (callback) { this.updatedCallbacks = this.updatedCallbacks || []; this.updatedCallbacks.push(callback); }, boundsChangedCallback: function (bounds) { this.boundsChangedCallbacks = this.boundsChangedCallbacks || []; $.each(this.boundsChangedCallbacks, function (index, callback) { callback(bounds); }); }, addBoundsChangedCallback: function (callback) { this.boundsChangedCallbacks = this.boundsChangedCallbacks || []; this.boundsChangedCallbacks.push(callback); }, centerUpdatedCallback: function (coordinates, accuracy, identifier) { this.centerUpdatedCallbacks = this.centerUpdatedCallbacks || []; $.each(this.centerUpdatedCallbacks, function (index, callback) { callback(coordinates, accuracy, identifier); }); }, addCenterUpdatedCallback: function (callback) { this.centerUpdatedCallbacks = this.centerUpdatedCallbacks || []; this.centerUpdatedCallbacks.push(callback); }, markerAddedCallback: function (marker) { this.markerAddedCallbacks = this.markerAddedCallbacks || []; $.each(this.markerAddedCallbacks, function (index, callback) { callback(marker); }); }, addMarkerAddedCallback: function (callback, existing) { existing = existing || true; if (existing) { $.each(this.mapMarkers, function (index, marker) { callback(marker); }); } this.markerAddedCallbacks = this.markerAddedCallbacks || []; this.markerAddedCallbacks.push(callback); }, markerRemoveCallback: function (marker) { this.markerRemoveCallbacks = this.markerRemoveCallbacks || []; $.each(this.markerRemoveCallbacks, function (index, callback) { callback(marker); }); }, addMarkerRemoveCallback: function (callback) { this.markerRemoveCallbacks = this.markerRemoveCallbacks || []; this.markerRemoveCallbacks.push(callback); }, populatedCallback: function () { this.populatedCallbacks = this.populatedCallbacks || []; while (this.populatedCallbacks.length > 0) { this.populatedCallbacks.shift()(this); } this.populated = true; }, addPopulatedCallback: function (callback) { if (this.populated) { callback(this); } else { this.populatedCallbacks = this.populatedCallbacks || []; this.populatedCallbacks.push(callback); } }, loadMarkersFromContainer: function () { var locations = []; this.wrapper.find('.geolocation-location').each(function (index, locationWrapperElement) { var locationWrapper = $(locationWrapperElement); var position = { lat: Number(locationWrapper.data('lat')), lng: Number(locationWrapper.data('lng')) }; /** @type {GeolocationMapMarker} */ var location = { position: position, title: locationWrapper.find('.location-title').text().trim(), setMarker: true, locationWrapper: locationWrapper }; if (typeof locationWrapper.data('icon') !== 'undefined') { location.icon = locationWrapper.data('icon').toString(); } if (typeof locationWrapper.data('label') !== 'undefined') { location.label = locationWrapper.data('label').toString(); } if (locationWrapper.data('set-marker') === 'false') { location.setMarker = false; } locations.push(location); }); return locations; }, loadShapesFromContainer: function () { var shapes = []; this.wrapper.find('.geolocation-shape').each(function (index, shapeWrapperElement) { var shapeWrapper = $(shapeWrapperElement); var meta = shapeWrapper.find('span[typeof="GeoShape"] meta').first(); if (meta.length === 0) { return; } var type = meta.attr('property').toString(); var coordinates = []; $.each(meta.attr('content').toString().split(' '), function (index, rawCoordinate) { var coordinate = rawCoordinate.split(','); if ( coordinate[0].length === 0 || coordinate[1].length === 0 ) { return; } coordinates.push({ lat: parseFloat(coordinate[0]), lng: parseFloat(coordinate[1]) }); }); /** @type {GeolocationShape} */ var shape = { coordinates: coordinates, shape: type, shapeWrapper: shapeWrapper }; switch (type) { case 'line': shape.title = shapeWrapper.find('.polyline-title').text().trim(); break; case 'polygon': shape.title = shapeWrapper.find('.polygon-title').text().trim(); if (typeof shapeWrapper.data('fillColor') !== 'undefined') { shape.fillColor = shapeWrapper.data('fillColor').toString(); } if (typeof shapeWrapper.data('fillOpacity') !== 'undefined') { shape.fillOpacity = parseFloat(shapeWrapper.data('fillOpacity').toString()); } break; } if (typeof shapeWrapper.data('strokeColor') !== 'undefined') { shape.strokeColor = shapeWrapper.data('strokeColor').toString(); } if (typeof shapeWrapper.data('strokeWidth') !== 'undefined') { shape.strokeWidth = parseInt(shapeWrapper.data('strokeWidth').toString()); } if (typeof shapeWrapper.data('strokeOpacity') !== 'undefined') { shape.strokeOpacity = parseFloat(shapeWrapper.data('strokeOpacity').toString()); } shapes.push(shape); }); return shapes; }, boundariesNormalized: function (boundaries) { if (typeof boundaries.north === 'number' && typeof boundaries.east === 'number' && typeof boundaries.south === 'number' && typeof boundaries.west === 'number' ) { return true; } return false; }, normalizeBoundaries: function (boundaries) { var that = this; if (that.boundariesNormalized(boundaries)) { return boundaries; } if ( typeof boundaries.north !== 'undefined' && typeof boundaries.south !== 'undefined' && typeof boundaries.east !== 'undefined' && typeof boundaries.west !== 'undefined' ) { var castBoundaries = { north: Number(boundaries.north), east: Number(boundaries.east), south: Number(boundaries.south), west: Number(boundaries.west) }; if (that.boundariesNormalized(castBoundaries)) { return castBoundaries; } } $.each(Drupal.geolocation.MapProviders, function (type, name) { if (typeof Drupal.geolocation[name].prototype.normalizeBoundaries !== 'undefined') { var normalizedBoundaries = Drupal.geolocation[name].prototype.normalizeBoundaries.call(null, boundaries); } if (that.boundariesNormalized(normalizedBoundaries)) { boundaries = normalizedBoundaries; return false; } }); if (that.boundariesNormalized(boundaries)) { return boundaries; } return false; } }; Drupal.geolocation.GeolocationMapBase = GeolocationMapBase; /** * Factory creating map instances. * * @constructor * * @param {GeolocationMapSettings} mapSettings The map settings. * @param {Boolean} [reset] Force creation of new map. * * @return {GeolocationMapInterface|boolean} Un-initialized map. */ function Factory(mapSettings, reset) { reset = reset || false; mapSettings.type = mapSettings.type || 'google_maps'; var map = null; /** * Previously stored map. * @type {boolean|GeolocationMapInterface} */ var existingMap = Drupal.geolocation.getMapById(mapSettings.id); if (reset === true || !existingMap) { if (typeof Drupal.geolocation[Drupal.geolocation.MapProviders[mapSettings.type]] !== 'undefined') { var mapProvider = Drupal.geolocation[Drupal.geolocation.MapProviders[mapSettings.type]]; map = new mapProvider(mapSettings); Drupal.geolocation.maps.push(map); } } else { map = existingMap; map.updatedCallback(mapSettings); } if (!map) { console.error("Map could not be initialized."); // eslint-disable-line no-console . return false; } if (typeof map.container === 'undefined') { console.error("Map container not set."); // eslint-disable-line no-console . return false; } if (map.container.length !== 1) { console.error("Map container not unique."); // eslint-disable-line no-console . return false; } return map; } Drupal.geolocation.Factory = Factory; /** * @type {Object} */ Drupal.geolocation.MapProviders = {}; Drupal.geolocation.addMapProvider = function (type, name) { Drupal.geolocation.MapProviders[type] = name; }; /** * Get map by ID. * * @param {String} id - Map ID to retrieve. * * @return {GeolocationMapInterface|boolean} - Retrieved map or false. */ Drupal.geolocation.getMapById = function (id) { var map = false; $.each(Drupal.geolocation.maps, function (index, currentMap) { if (currentMap.id === id) { map = currentMap; } }); if (!map) { return false; } if (typeof map.container === 'undefined') { console.error("Existing map container not set."); // eslint-disable-line no-console . return false; } if (map.container.length !== 1) { console.error("Existing map container not unique."); // eslint-disable-line no-console . return false; } return map; }; /** * @typedef {Object} GeolocationMapFeatureSettings * * @property {String} id * @property {boolean} enabled * @property {boolean} executed */ /** * Callback when map is clicked. * * @callback GeolocationMapFeatureCallback * * @param {GeolocationMapInterface} map - Map. * @param {GeolocationMapFeatureSettings} featureSettings - Settings. * * @return {boolean} - Executed successfully. */ /** * Get map by ID. * * @param {String} featureId - Map ID to retrieve. * @param {GeolocationMapFeatureCallback} callback - Retrieved map or false. * @param {Object} drupalSettings - Drupal settings. */ Drupal.geolocation.executeFeatureOnAllMaps = function (featureId, callback, drupalSettings) { if (typeof drupalSettings.geolocation === 'undefined') { return false; } $.each( drupalSettings.geolocation.maps, /** * @param {String} mapId - ID of current map * @param {Object} mapSettings - settings for current map * @param {GeolocationMapFeatureSettings} mapSettings[featureId] - Feature settings for current map */ function (mapId, mapSettings) { if (typeof mapSettings[featureId] === 'undefined') { return; } if (!mapSettings[featureId].enable) { return; } var map = Drupal.geolocation.getMapById(mapId); if (!map) { return; } map.features = map.features || {}; map.features[featureId] = map.features[featureId] || {}; if (typeof map.features[featureId].executed === 'undefined') { map.features[featureId].executed = false; } if (map.features[featureId].executed) { return; } map.addPopulatedCallback(function (map) { if (map.features[featureId].executed) { return; } var result = callback(map, mapSettings[featureId]); if (result === true) { map.features[featureId].executed = true; } }); } ); }; })(jQuery, Drupal); ; /** * @file * Javascript for the Geolocation map formatter. */ (function ($, Drupal) { 'use strict'; /** * Find and display all maps. * * @type {Drupal~behavior} * * @prop {Drupal~behaviorAttach} attach * Attaches Geolocation Maps formatter functionality to relevant elements. */ Drupal.behaviors.geolocationMap = { /** * @param context * @param drupalSettings * @param {Object} drupalSettings.geolocation */ attach: function (context, drupalSettings) { $('.geolocation-map-wrapper').once('geolocation-map-processed').each(function (index, item) { var mapWrapper = $(item); var mapSettings = {}; var reset = false; mapSettings.id = mapWrapper.attr('id'); mapSettings.wrapper = mapWrapper; if (mapWrapper.length === 0) { return; } mapSettings.lat = 0; mapSettings.lng = 0; if ( mapWrapper.data('centre-lat') && mapWrapper.data('centre-lng') ) { mapSettings.lat = Number(mapWrapper.data('centre-lat')); mapSettings.lng = Number(mapWrapper.data('centre-lng')); } if (mapWrapper.data('map-type')) { mapSettings.type = mapWrapper.data('map-type'); } if (typeof drupalSettings.geolocation === 'undefined') { console.error("Bailing out for lack of settings."); // eslint-disable-line no-console . return; } $.each(drupalSettings.geolocation.maps, function (mapId, currentSettings) { if (mapId === mapSettings.id) { mapSettings = $.extend(currentSettings, mapSettings); } }); if (mapWrapper.parent().hasClass('preview-section')) { if (mapWrapper.parentsUntil('#views-live-preview').length) { reset = true; } } var map = Drupal.geolocation.Factory(mapSettings, reset); if (!map) { mapWrapper.removeOnce('geolocation-map-processed'); return; } map.addInitializedCallback(function (map) { map.removeControls(); $('.geolocation-map-controls > *', map.wrapper).each(function (index, control) { map.addControl(control); }); map.removeMapMarkers(); var locations = map.loadMarkersFromContainer(); $.each(locations, function (index, location) { map.setMapMarker(location); }); map.removeShapes(); var shapes = map.loadShapesFromContainer(); $.each(shapes, function (index, shape) { map.addShape(shape); }); map.setCenter(); map.wrapper.find('.geolocation-location').hide(); }); map.addUpdatedCallback(function (map, mapSettings) { map.settings = $.extend(map.settings, mapSettings.settings); map.wrapper = mapSettings.wrapper; mapSettings.wrapper.find('.geolocation-map-container').replaceWith(map.container); map.lat = mapSettings.lat; map.lng = mapSettings.lng; if (typeof mapSettings.map_center !== 'undefined') { map.mapCenter = mapSettings.map_center; } }); }); }, detach: function (context, drupalSettings) {} }; })(jQuery, Drupal); ; /** * @file * Handle the common map. */ /** * @name CommonMapUpdateSettings * @property {String} enable * @property {String} hide_form * @property {number} views_refresh_delay * @property {String} update_view_id * @property {String} update_view_display_id * @property {String} boundary_filter * @property {String} parameter_identifier */ /** * @name CommonMapSettings * @property {Object} settings * @property {CommonMapUpdateSettings} dynamic_map * @property {Boolean} markerScrollToResult */ /** * @property {CommonMapSettings[]} drupalSettings.geolocation.commonMap */ (function ($, window, Drupal) { 'use strict'; /** * Attach common map style functionality. * * @type {Drupal~behavior} * * @prop {Drupal~behaviorAttach} attach * Attaches common map style functionality to relevant elements. */ Drupal.behaviors.geolocationCommonMap = { /** * @param {GeolocationSettings} drupalSettings.geolocation */ attach: function (context, drupalSettings) { if (typeof drupalSettings.geolocation === 'undefined') { return; } $.each( drupalSettings.geolocation.commonMap, /** * @param {String} mapId - ID of current map * @param {CommonMapSettings} commonMapSettings - settings for current map */ function (mapId, commonMapSettings) { var map = Drupal.geolocation.getMapById(mapId); if (!map) { return; } /* * Hide form if requested. */ if ( typeof commonMapSettings.dynamic_map !== 'undefined' && commonMapSettings.dynamic_map.enable && commonMapSettings.dynamic_map.hide_form && typeof commonMapSettings.dynamic_map.parameter_identifier !== 'undefined' ) { var exposedForm = $('form#views-exposed-form-' + commonMapSettings.dynamic_map.update_view_id.replace(/_/g, '-') + '-' + commonMapSettings.dynamic_map.update_view_display_id.replace(/_/g, '-')); if (exposedForm.length === 1) { exposedForm.find('input[name^="' + commonMapSettings.dynamic_map.parameter_identifier + '"]').each(function (index, item) { $(item).parent().hide(); }); // Hide entire form if it's empty now, except form-submit. if (exposedForm.find('input:visible:not(.form-submit), select:visible').length === 0) { exposedForm.hide(); } } } } ); }, detach: function (context, drupalSettings) {} }; Drupal.geolocation.commonMap = Drupal.geolocation.commonMap || {}; Drupal.geolocation.commonMap.dynamicMapViewsAjaxSettings = function (commonMapSettings) { // Make sure to load current form DOM element, which will change after every AJAX operation. var view = $('.view-id-' + commonMapSettings.dynamic_map.update_view_id + '.view-display-id-' + commonMapSettings.dynamic_map.update_view_display_id); if (view.length === 0) { console.error("Geolocation - No common map container found."); return; } if (typeof commonMapSettings.dynamic_map.boundary_filter === 'undefined') { return; } // Extract the view DOM ID from the view classes. var matches = /(js-view-dom-id-\w+)/.exec(view.attr('class').toString()); var currentViewId = matches[1].replace('js-view-dom-id-', 'views_dom_id:'); var viewInstance = Drupal.views.instances[currentViewId]; var ajaxSettings = $.extend(true, {}, viewInstance.element_settings); ajaxSettings.progress.type = 'none'; var exposedForm = $('form#views-exposed-form-' + commonMapSettings.dynamic_map.update_view_id.replace(/_/g, '-') + '-' + commonMapSettings.dynamic_map.update_view_display_id.replace(/_/g, '-')); if (exposedForm.length) { // Add form values. jQuery.each(exposedForm.serializeArray(), function (index, field) { var add = {}; add[field.name] = field.value; ajaxSettings.submit = $.extend(ajaxSettings.submit, add); }); } // Trigger geolocation bounds specific behavior. ajaxSettings.submit = $.extend(ajaxSettings.submit, {geolocation_common_map_dynamic_view: true}); return ajaxSettings; }; })(jQuery, window, Drupal); ; /** * @file * Fit locations. */ (function (Drupal) { 'use strict'; Drupal.geolocation = Drupal.geolocation || {}; Drupal.geolocation.mapCenter = Drupal.geolocation.mapCenter || {}; /** * @param {GeolocationMapInterface} map * @param {GeolocationCenterOption} centerOption * @param {Boolean} centerOption.settings.reset_zoom * @param {Boolean} centerOption.settings.min_zoom */ Drupal.geolocation.mapCenter.fit_bounds = function (map, centerOption) { if (typeof map.mapMarkers === "undefined") { return false; } if (map.mapMarkers.length === 0) { return false; } map.fitMapToMarkers(); if (centerOption.settings.reset_zoom) { map.setZoom(undefined, true); } else if (centerOption.settings.min_zoom) { map.getZoom().then(function (zoom) { if (centerOption.settings.min_zoom < zoom) { map.setZoom(centerOption.settings.min_zoom); } }); } return true; } })(Drupal); ; /** * @file * Javascript for leaflet integration. */ (function ($, Drupal) { 'use strict'; /** * GeolocationLeafletMap element. * * @constructor * @augments {GeolocationMapBase} * @implements {GeolocationMapInterface} * @inheritDoc * * @prop {Map} leafletMap * @prop {L.LayerGroup} markerLayer * @prop {TileLayer} tileLayer * @prop {Object} settings.leaflet_settings - Leaflet specific settings. */ function GeolocationLeafletMap(mapSettings) { var leafletPromise = new Promise(function (resolve, reject) { if (typeof L === 'undefined') { setTimeout(function () { if (typeof L === 'undefined') { reject(); } else { resolve(); } }, 1000); } else { resolve(); } }); this.type = 'leaflet'; Drupal.geolocation.GeolocationMapBase.call(this, mapSettings); /** * * @type {MapOptions} */ var defaultLeafletSettings = { zoom: 10 }; // Add any missing settings. this.settings.leaflet_settings = $.extend(defaultLeafletSettings, this.settings.leaflet_settings); // Set the container size. this.container.css({ height: this.settings.leaflet_settings.height, width: this.settings.leaflet_settings.width }); var that = this; leafletPromise.then(function () { var leafletMapSettings = that.settings.leaflet_settings; leafletMapSettings.center = [that.lat, that.lng]; leafletMapSettings.zoomControl = false; leafletMapSettings.attributionControl = false; leafletMapSettings.crs = L.CRS[that.settings.leaflet_settings.crs]; /** @type {Map} */ var leafletMap = L.map(that.container.get(0), leafletMapSettings); var markerLayer = L.layerGroup().addTo(leafletMap); // Set the tile layer. var tileLayer = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(leafletMap); that.leafletMap = leafletMap; that.markerLayer = markerLayer; that.tileLayer = tileLayer; that.addPopulatedCallback(function (map) { var singleClick; map.leafletMap.on('click', /** @param {LeafletMouseEvent} e */ function (e) { singleClick = setTimeout(function () { map.clickCallback({lat: e.latlng.lat, lng: e.latlng.lng}); }, 500); }); map.leafletMap.on('dblclick', /** @param {LeafletMouseEvent} e */ function (e) { clearTimeout(singleClick); map.doubleClickCallback({lat: e.latlng.lat, lng: e.latlng.lng}); }); map.leafletMap.on('contextmenu', /** @param {LeafletMouseEvent} e */ function (e) { map.contextClickCallback({lat: e.latlng.lat, lng: e.latlng.lng}); }); map.leafletMap.on('moveend', /** @param {LeafletEvent} e */ function (e) { map.boundsChangedCallback(map.leafletMap.getBounds()); }); }); that.initializedCallback(); that.populatedCallback(); }) .catch(function (error) { console.error('Leaflet library not loaded. Bailing out. Error:'); // eslint-disable-line no-console. console.error(error); }); } GeolocationLeafletMap.prototype = Object.create(Drupal.geolocation.GeolocationMapBase.prototype); GeolocationLeafletMap.prototype.constructor = GeolocationLeafletMap; GeolocationLeafletMap.prototype.getZoom = function () { var that = this; return new Promise(function (resolve, reject) { resolve(that.leafletMap.getZoom()); }); }; GeolocationLeafletMap.prototype.setZoom = function (zoom, defer) { if (typeof zoom === 'undefined') { zoom = this.settings.leaflet_settings.zoom; } zoom = parseInt(zoom); this.leafletMap.setZoom(zoom); }; GeolocationLeafletMap.prototype.setCenterByCoordinates = function (coordinates, accuracy, identifier) { Drupal.geolocation.GeolocationMapBase.prototype.setCenterByCoordinates.call(this, coordinates, accuracy, identifier); if (typeof accuracy === 'undefined') { this.leafletMap.panTo(coordinates); return; } var circle = this.addAccuracyIndicatorCircle(coordinates, accuracy); this.leafletMap.fitBounds(circle.getBounds()); setInterval(fadeCityCircles, 300); function fadeCityCircles() { var fillOpacity = circle.options.fillOpacity; fillOpacity -= 0.03; var opacity = circle.options.opacity; opacity -= 0.06; if ( opacity > 0 && fillOpacity > 0 ) { circle.setStyle({ fillOpacity: fillOpacity, stroke: opacity }); } else { circle.remove() } } }; GeolocationLeafletMap.prototype.addAccuracyIndicatorCircle = function (location, accuracy) { return L.circle(location, accuracy, { interactive: false, color: '#4285F4', opacity: 0.3, fillColor: '#4285F4', fillOpacity: 0.15 }).addTo(this.leafletMap); }; GeolocationLeafletMap.prototype.setMapMarker = function (markerSettings) { if (typeof markerSettings.setMarker !== 'undefined') { if (markerSettings.setMarker === false) { return; } } if (typeof markerSettings.icon === 'string') { markerSettings.icon = L.icon({ iconUrl: markerSettings.icon }); } /** @type {Marker} */ var currentMarker = L.marker([parseFloat(markerSettings.position.lat), parseFloat(markerSettings.position.lng)], markerSettings).addTo(this.markerLayer); currentMarker.locationWrapper = markerSettings.locationWrapper; if (typeof markerSettings.label === 'string') { currentMarker.bindTooltip(markerSettings.label, { permanent: true, direction: 'top' }); } Drupal.geolocation.GeolocationMapBase.prototype.setMapMarker.call(this, currentMarker); return currentMarker; }; GeolocationLeafletMap.prototype.removeMapMarker = function (marker) { Drupal.geolocation.GeolocationMapBase.prototype.removeMapMarker.call(this, marker); this.markerLayer.removeLayer(marker); }; GeolocationLeafletMap.prototype.addShape = function (shapeSettings) { if (typeof shapeSettings === 'undefined') { return; } var coordinates = []; $.each(shapeSettings.coordinates, function (index, coordinate) { coordinates.push([coordinate.lat, coordinate.lng]); }); var shape; switch (shapeSettings.shape) { case 'line': shape = L.polyline(coordinates, { color: shapeSettings.strokeColor, opacity: shapeSettings.strokeOpacity, weight: shapeSettings.strokeWidth }); if (shapeSettings.title) { shape.bindTooltip(shapeSettings.title); } break; case 'polygon': shape = L.polygon(coordinates, { color: shapeSettings.strokeColor, opacity: shapeSettings.strokeOpacity, weight: shapeSettings.strokeWidth, fillColor: shapeSettings.fillColor, fillOpacity: shapeSettings.fillOpacity }); if (shapeSettings.title) { shape.bindTooltip(shapeSettings.title); } break; } shape.addTo(this.leafletMap); Drupal.geolocation.GeolocationMapBase.prototype.addShape.call(this, shape); return shape; }; GeolocationLeafletMap.prototype.removeShape = function (shape) { if (typeof shape === 'undefined') { return; } Drupal.geolocation.GeolocationMapBase.prototype.removeShape.call(this, shape); shape.remove(); }; GeolocationLeafletMap.prototype.getMarkerBoundaries = function (locations) { locations = locations || this.mapMarkers; if (locations.length === 0) { return; } var group = new L.featureGroup(locations); return group.getBounds(); }; GeolocationLeafletMap.prototype.getCenter = function () { var center = this.leafletMap.getCenter(); return {lat: center.lat, lng: center.lng}; }; GeolocationLeafletMap.prototype.normalizeBoundaries = function (boundaries) { if (boundaries instanceof L.LatLngBounds) { return { north: boundaries.getNorth(), east: boundaries.getEast(), south: boundaries.getSouth(), west: boundaries.getWest() }; } return false; }; GeolocationLeafletMap.prototype.denormalizeBoundaries = function (boundaries) { if (typeof boundaries === 'undefined') { return false; } if (boundaries instanceof L.LatLngBounds) { return boundaries; } if (Drupal.geolocation.GeolocationMapBase.prototype.boundariesNormalized.call(this, boundaries)) { return L.latLngBounds([ [boundaries.south, boundaries.west], [boundaries.north, boundaries.east] ]); } else { boundaries = Drupal.geolocation.GeolocationMapBase.prototype.normalizeBoundaries.call(this, boundaries); if (boundaries) { return L.latLngBounds([ [boundaries.south, boundaries.west], [boundaries.north, boundaries.east] ]); } } return false; }; GeolocationLeafletMap.prototype.fitBoundaries = function (boundaries, identifier) { boundaries = this.denormalizeBoundaries(boundaries); if (!boundaries) { return; } if (!this.leafletMap.getBounds().equals(boundaries)) { this.leafletMap.fitBounds(boundaries); Drupal.geolocation.GeolocationMapBase.prototype.fitBoundaries.call(this, boundaries, identifier); } }; GeolocationLeafletMap.prototype.addControl = function (element) { this.leafletMap.controls = this.leafletMap.controls || []; var controlElement = new(L.Control.extend({ options: { position: typeof element.dataset.controlPosition === 'undefined' ? 'topleft' : element.dataset.controlPosition }, onAdd: function (map) { element.style.display = 'block'; L.DomEvent.disableClickPropagation(element); return element; } })); controlElement.addTo(this.leafletMap); this.leafletMap.controls.push(controlElement); }; GeolocationLeafletMap.prototype.removeControls = function () { this.leafletMap.controls = this.leafletMap.controls || []; var that = this; $.each(this.leafletMap.controls, function (index, control) { that.leafletMap.removeControl(control); }); }; Drupal.geolocation.GeolocationLeafletMap = GeolocationLeafletMap; Drupal.geolocation.addMapProvider('leaflet', 'GeolocationLeafletMap'); })(jQuery, Drupal); ; /** * @file * Common Map Leaflet. */ (function ($, Drupal) { 'use strict'; /** * Dynamic map handling aka "AirBnB mode". * * @type {Drupal~behavior} * * @prop {Drupal~behaviorAttach} attach * Attaches common map style functionality to relevant elements. */ Drupal.behaviors.geolocationCommonMapLeaflet = { /** * @param {GeolocationSettings} drupalSettings.geolocation */ attach: function (context, drupalSettings) { $.each( drupalSettings.geolocation.commonMap, /** * @param {String} mapId - ID of current map * @param {CommonMapSettings} commonMapSettings - settings for current map */ function (mapId, commonMapSettings) { if ( typeof commonMapSettings.dynamic_map !== 'undefined' && commonMapSettings.dynamic_map.enable ) { var map = Drupal.geolocation.getMapById(mapId); if (!map) { return; } if (map.container.hasClass('geolocation-common-map-leaflet-processed')) { return; } map.container.addClass('geolocation-common-map-leaflet-processed'); /** * Update the view depending on dynamic map settings and capability. * * One of several states might occur now. Possible state depends on whether: * - view using AJAX is enabled * - map view is the containing (page) view or an attachment * - the exposed form is present and contains the boundary filter * - map settings are consistent * * Given these factors, map boundary changes can be handled in one of three ways: * - trigger the views AJAX "RefreshView" command * - trigger the exposed form causing a regular POST reload * - fully reload the website * * These possibilities are ordered by UX preference. */ if ( map.container.length && map.type === 'leaflet' ) { map.addPopulatedCallback(function (map) { var geolocationMapIdleTimer; map.leafletMap.on('moveend zoomend', /** @param {LeafletMouseEvent} e */function (e) { clearTimeout(geolocationMapIdleTimer); geolocationMapIdleTimer = setTimeout( function () { var ajaxSettings = Drupal.geolocation.commonMap.dynamicMapViewsAjaxSettings(commonMapSettings); // Add bounds. var currentBounds = map.leafletMap.getBounds(); var bound_parameters = {}; bound_parameters[commonMapSettings['dynamic_map']['parameter_identifier'] + '[lat_north_east]'] = currentBounds.getNorthEast().lat; bound_parameters[commonMapSettings['dynamic_map']['parameter_identifier'] + '[lng_north_east]'] = currentBounds.getNorthEast().lng; bound_parameters[commonMapSettings['dynamic_map']['parameter_identifier'] + '[lat_south_west]'] = currentBounds.getSouthWest().lat; bound_parameters[commonMapSettings['dynamic_map']['parameter_identifier'] + '[lng_south_west]'] = currentBounds.getSouthWest().lng; ajaxSettings.submit = $.extend( ajaxSettings.submit, bound_parameters ); Drupal.ajax(ajaxSettings).execute(); }, commonMapSettings.dynamic_map.views_refresh_delay ); }); }); } } }); }, detach: function (context, drupalSettings) {} }; })(jQuery, Drupal); ; /** * @file * Custom tile layer. */ /** * @typedef {Object} CustomTileLayerSettings * * @extends {GeolocationMapFeatureSettings} * * @property {String} tileLayerUrl * @property {String} tileLayerAttribution * @property {String} tileLayerSubdomains * @property {Number} tileLayerZoom */ (function (Drupal) { 'use strict'; /** * Custom Tile Layer. * * @type {Drupal~behavior} * * @prop {Drupal~behaviorAttach} attach * Attaches Custom Tile Layer functionality to relevant elements. */ Drupal.behaviors.leafletCustomTileLayer = { attach: function (context, drupalSettings) { Drupal.geolocation.executeFeatureOnAllMaps( 'leaflet_custom_tile_layer', /** * @param {GeolocationLeafletMap} map - Current map. * @param {CustomTileLayerSettings} featureSettings - Settings for current feature. */ function (map, featureSettings) { map.tileLayer.remove(); map.tileLayer = L.tileLayer(featureSettings.tileLayerUrl, { attribution: featureSettings.tileLayerAttribution, subdomains: featureSettings.tileLayerSubdomains, maxZoom: featureSettings.tileLayerZoom }).addTo(map.leafletMap); return true; }, drupalSettings ); }, detach: function (context, drupalSettings) {} }; })(Drupal); ; /** * @file * Control Zoom. */ /** * @typedef {Object} ControlZoomSettings * * @extends {GeolocationMapFeatureSettings} * * @property {String} position */ (function (Drupal) { 'use strict'; /** * Zoom control. * * @type {Drupal~behavior} * * @prop {Drupal~behaviorAttach} attach * Attaches common map zoom functionality to relevant elements. */ Drupal.behaviors.leafletControlZoom = { attach: function (context, drupalSettings) { Drupal.geolocation.executeFeatureOnAllMaps( 'leaflet_control_zoom', /** * @param {GeolocationLeafletMap} map - Current map. * @param {ControlZoomSettings} featureSettings - Settings for current feature. */ function (map, featureSettings) { L.control.zoom({ position: featureSettings.position }).addTo(map.leafletMap); return true; }, drupalSettings ); }, detach: function (context, drupalSettings) {} }; })(Drupal); ; /** * @file * Marker Popup. */ /** * @typedef {Object} LeafletMarkerPopupSettings * * @extends {GeolocationMapFeatureSettings} * * @property {Boolean} infoAutoDisplay * @property {Number} maxWidth * @property {Number} minWidth * @property {Number} maxHeight * @property {Boolean} autoPan * @property {Boolean} keepInView * @property {Boolean} closeButton * @property {Boolean} autoClose * @property {Boolean} closeOnEscapeKey * @property {String} className */ (function ($, Drupal) { 'use strict'; /** * Marker Popup. * * @type {Drupal~behavior} * * @prop {Drupal~behaviorAttach} attach * Attaches common map marker popup functionality to relevant elements. */ Drupal.behaviors.leafletMarkerPopup = { attach: function (context, drupalSettings) { Drupal.geolocation.executeFeatureOnAllMaps( 'leaflet_marker_popup', /** * @param {GeolocationLeafletMap} map - Current map. * @param {LeafletMarkerPopupSettings} featureSettings - Settings for current feature. */ function (map, featureSettings) { var geolocationLeafletPopupHandler = function (currentMarker) { if (typeof (currentMarker.locationWrapper) === 'undefined') { return; } var content = currentMarker.locationWrapper.find('.location-content'); if (content.length < 1) { return; } var popupOptions = {}; /** * 'maxWidth' => $feature_settings['max_width'], 'minWidth' => $feature_settings['min_width'], 'maxHeight' => $feature_settings['max_height'], 'autoPan' => $feature_settings['auto_pan'], 'keepInView' => $feature_settings['keep_in_view'], 'closeButton' => $feature_settings['close_button'], 'autoClose' => $feature_settings['auto_close'], 'closeOnEscapeKey' => $feature_settings['close_on_escape_key'], 'className' => $feature_settings['class_name'], */ if (featureSettings.maxWidth) { popupOptions.maxWidth = Math.round(featureSettings.maxWidth); } if (featureSettings.minWidth) { popupOptions.minWidth = Math.round(featureSettings.minWidth); } if (featureSettings.maxHeight) { popupOptions.maxHeight = Math.round(featureSettings.maxHeight); } if (typeof featureSettings.autoPan !== "undefined") { popupOptions.autoPan = featureSettings.autoPan; } if (typeof featureSettings.keepInView !== "undefined") { popupOptions.keepInView = featureSettings.keepInView; } if (typeof featureSettings.closeButton !== "undefined") { popupOptions.closeButton = featureSettings.closeButton; } if (typeof featureSettings.autoClose !== "undefined") { popupOptions.autoClose = featureSettings.autoClose; } if (typeof featureSettings.closeOnEscapeKey !== "undefined") { popupOptions.closeOnEscapeKey = featureSettings.closeOnEscapeKey; } if (featureSettings.className) { popupOptions.className = featureSettings.className; } currentMarker.bindPopup(content.html(), popupOptions); if (featureSettings.infoAutoDisplay) { currentMarker.openPopup(); } }; map.addPopulatedCallback(function (map) { $.each(map.mapMarkers, function (index, currentMarker) { geolocationLeafletPopupHandler(currentMarker); }); }); map.addMarkerAddedCallback(function (currentMarker) { geolocationLeafletPopupHandler(currentMarker); }); return true; }, drupalSettings ); }, detach: function (context, drupalSettings) {} }; })(jQuery, Drupal); ; /** * @file * Marker Clusterer. */ (function (Drupal) { 'use strict'; /** * Marker Clusterer. * * @type {Drupal~behavior} * * @prop {Drupal~behaviorAttach} attach * Attaches common map marker cluster functionality to relevant elements. */ Drupal.behaviors.leafletMarkerClusterer = { attach: function (context, drupalSettings) { Drupal.geolocation.executeFeatureOnAllMaps( 'leaflet_marker_clusterer', /** * @param {GeolocationLeafletMap} map - Current map. * @param {GeolocationMapFeatureSettings} featureSettings - Settings for current feature. * @param {String} featureSettings.zoomToBoundsOnClick - Settings for current feature. * @param {String} featureSettings.showCoverageOnHover - Settings for current feature. * @param {int} featureSettings.disableClusteringAtZoom - Settings for current feature. * @param {Object} featureSettings.customMarkerSettings - Settings for current feature. * * @see https://github.com/Leaflet/Leaflet.markercluster */ function (map, featureSettings) { var options = { showCoverageOnHover: false, zoomToBoundsOnClick: false, disableClusteringAtZoom: null }; if (featureSettings.zoomToBoundsOnClick) { options.zoomToBoundsOnClick = true; } if (featureSettings.showCoverageOnHover) { options.showCoverageOnHover = true; } if (featureSettings.disableClusteringAtZoom) { options.disableClusteringAtZoom = featureSettings.disableClusteringAtZoom; } if (featureSettings.customMarkerSettings) { options.iconCreateFunction = function (cluster) { var childCount = cluster.getChildCount(); var customMarkers = featureSettings.customMarkerSettings; var className = ' marker-cluster-'; var radius = 40; for (var size in customMarkers) { if (childCount < customMarkers[size].limit) { className += size; radius = customMarkers[size].radius; break; } } return new L.DivIcon({ html: '
    ' + childCount + '
    ', className: 'marker-cluster' + className, iconSize: new L.Point(radius, radius) }); }; } var cluster = L.markerClusterGroup(options); map.leafletMap.removeLayer(map.markerLayer); cluster.addLayer(map.markerLayer); map.leafletMap.addLayer(cluster); map.addMarkerAddedCallback(function (currentMarker) { cluster.addLayer(currentMarker); }); map.addMarkerRemoveCallback(function (marker) { cluster.removeLayer(marker); }); return true; }, drupalSettings ); }, detach: function (context, drupalSettings) { } }; })(Drupal); ; /** * @file * Gesture handling. */ (function (Drupal) { 'use strict'; /** * Gesture handling. * * @type {Drupal~behavior} * * @prop {Drupal~behaviorAttach} attach * Attaches common map gesture handling functionality to relevant elements. */ Drupal.behaviors.leafletGestureHandling = { attach: function (context, drupalSettings) { Drupal.geolocation.executeFeatureOnAllMaps( 'leaflet_gesture_handling', /** * @param {GeolocationLeafletMap} map - Current map. * @param {GeolocationMapFeatureSettings} featureSettings - Settings for current feature. */ function (map, featureSettings) { L.Util.setOptions(map.leafletMap, { gestureHandlingOptions: { duration: 1000 } }); map.leafletMap['gestureHandling'].enable(); return true; }, drupalSettings ); }, detach: function (context, drupalSettings) {} }; })(Drupal); ; /** * @file * Marker Icon. */ /** * @typedef {Object} LeafletMarkerIconSettings * * @extends {GeolocationMapFeatureSettings} * * @property {String} markerIconPath * @property {Array} iconSize * @property {Number} iconSize.width * @property {Number} iconSize.height * @property {Array} iconAnchor * @property {Number} iconAnchor.x * @property {Number} iconAnchor.y * @property {Array} popupAnchor * @property {Number} popupAnchor.x * @property {Number} popupAnchor.y * @property {String} markerShadowPath * @property {Array} shadowSize * @property {Number} shadowSize.width * @property {Number} shadowSize.height * @property {Array} shadowAnchor * @property {Number} shadowAnchor.x * @property {Number} shadowAnchor.y */ (function ($, Drupal) { 'use strict'; /** * Marker Icon Adjustment. * * @type {Drupal~behavior} * * @prop {Drupal~behaviorAttach} attach * Attaches map marker icon adjustment functionality to relevant elements. */ Drupal.behaviors.leafletMarkerIcon = { attach: function (context, drupalSettings) { Drupal.geolocation.executeFeatureOnAllMaps( 'leaflet_marker_icon', /** * @param {GeolocationLeafletMap} map - Current map. * @param {LeafletMarkerIconSettings} featureSettings - Settings for current feature. */ function (map, featureSettings) { var geolocationLeafletIconHandler = function (currentMarker) { var iconUrl; if (typeof currentMarker.locationWrapper !== 'undefined') { var currentIcon = currentMarker.locationWrapper.data('icon'); } if (typeof currentIcon === 'undefined') { if (typeof featureSettings.markerIconPath === 'string') { iconUrl = featureSettings.markerIconPath; } else { return; } } else { iconUrl = currentIcon; } var iconOptions = { iconUrl: iconUrl, shadowUrl: featureSettings.markerShadowPath }; if (featureSettings.iconSize.width && featureSettings.iconSize.height) { $.extend(iconOptions, {iconSize: [featureSettings.iconSize.width, featureSettings.iconSize.height]}); } if (featureSettings.shadowSize.width && featureSettings.shadowSize.height) { $.extend(iconOptions, {shadowSize: [featureSettings.shadowSize.width, featureSettings.shadowSize.height]}); } if (featureSettings.iconAnchor.x || featureSettings.iconAnchor.y) { $.extend(iconOptions, {iconAnchor: [featureSettings.iconAnchor.x, featureSettings.iconAnchor.y]}); } if (featureSettings.shadowAnchor.x || featureSettings.shadowAnchor.y) { $.extend(iconOptions, {shadowAnchor: [featureSettings.shadowAnchor.x, featureSettings.shadowAnchor.y]}); } if (featureSettings.popupAnchor.x || featureSettings.popupAnchor.y) { $.extend(iconOptions, {popupAnchor: [featureSettings.popupAnchor.x, featureSettings.popupAnchor.y]}); } currentMarker.setIcon(L.icon(iconOptions)); }; map.addPopulatedCallback(function (map) { $.each(map.mapMarkers, function (index, currentMarker) { geolocationLeafletIconHandler(currentMarker); }); }); map.addMarkerAddedCallback(function (currentMarker) { geolocationLeafletIconHandler(currentMarker); }); return true; }, drupalSettings ); }, detach: function (context, drupalSettings) {} }; })(jQuery, Drupal); ; /** * @file * Control Zoom. */ /** * @typedef {Object} ControlAttributionSettings * * @extends {GeolocationMapFeatureSettings} * * @property {String} prefix * @property {String} position */ (function (Drupal) { 'use strict'; /** * Zoom control. * * @type {Drupal~behavior} * * @prop {Drupal~behaviorAttach} attach * Attaches common map zoom functionality to relevant elements. */ Drupal.behaviors.leafletControlAttribution = { attach: function (context, drupalSettings) { Drupal.geolocation.executeFeatureOnAllMaps( 'leaflet_control_attribution', /** * @param {GeolocationLeafletMap} map - Current map. * @param {ControlAttributionSettings} featureSettings - Settings for current feature. */ function (map, featureSettings) { L.control.attribution({ prefix: featureSettings.prefix + ' | © OpenStreetMap contributors', position: featureSettings.position }).addTo(map.leafletMap); return true; }, drupalSettings ); }, detach: function (context, drupalSettings) {} }; })(Drupal); ; (function ($, Drupal) { $(document).ready(function () { $('.header-bloco-governo-digital > a.btn-default').click(function (event) { //primeiro nível event.preventDefault(); temaId = $(this).attr('id'); listaId = 'servicos-' + temaId.substring(4, temaId.length); $('.box-servicos').removeClass('active'); $('.btn-pia i.fas').removeClass('fa-caret-up').addClass('fa-caret-down'); if ($(this).hasClass('active')) { $(this).removeClass('active'); } else { $('.header-bloco-governo-digital a.btn-default').removeClass('active'); $(this).addClass('active'); $('#' + listaId).addClass('active'); $(this).find('i.fas').removeClass('fa-caret-down').addClass('fa-caret-up'); } //corrigir a posição dos itens do mobile categoriasMobile($(this), listaId); }); $('.lista-categorias li a').click(function (event) { if ($(this).parent().find('ul').length != 0) { event.preventDefault(); $(this).parent().children('ul').slideToggle('fast'); } }); listaColunasQtde(); }); //exibir a lista mobile var categoriasMobile = function (item, listaId) { if ($(window).width() < 576) { $('.box-servicos').removeClass('active'); $('.box-servicos.mobile').remove(); if (item.hasClass('active')) { item.after('
    '); $('#' + listaId + '-mobile').html($('#' + listaId).html()); } $('#' + listaId + '-mobile a').click(function (event) { if ($(this).parent().find('ul').length != 0) { event.preventDefault(); $(this).parent().children('ul').slideToggle('fast'); } }); } }; //acertar a quantidade de colunas de acordo com a quantidade de itens var listaColunasQtde = function () { if ($(window).width() > 575) { $('#bloco-governo-digital .box-servicos ul.lista-categorias').each(function (index, el) { if ($(this).children('li').length == 2) { $(this).css('columnCount', 2); } else if ($(this).children('li').length == 1) { $(this).css('columnCount', 1); } }); } }; $(window).resize(function (event) { listaColunasQtde(); }); })(jQuery, Drupal); ; !function(o){o(document).ready(function(){o(".celeparheader .ativa-mobile").click(function(e){e.preventDefault(),"none"!=o(this).css("display")&&(o(this).css("display","none"),o(".celeparheader h1.logo").css("display","none"),o(".celeparheader .bloco-busca-pia").css("display","none"),o(".celeparheader .bloco-busca-pia").animate({width:"toggle"}))}),o(document).mouseup(function(e){if(o(".celeparheader .bloco-busca-pia").is(":visible")&&o(window).width()<768){e.preventDefault();var a=o(".celeparheader .bloco-busca-pia .campo-busca");a.is(e.target)||0!==a.has(e.target).length||(o(".celeparheader .bloco-busca-pia").animate({width:"toggle"}),o(".celeparheader .ativa-mobile").toggle("slow/400/fast"),o(".celeparheader h1.logo").toggle("slow/400/fast"))}})})}(jQuery);;